@resourge/react-fetch
Version:
[](LICENSE)
28 lines (26 loc) • 616 B
JavaScript
/**
* react-fetch v1.43.1
*
* Copyright (c) resourge.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
const throttleMethod = (method, threshold = 1000) => {
let lastCall = Date.now();
const _throttleMethod = (...args) => {
const now = Date.now();
if (now - lastCall > threshold) {
method(...args);
lastCall = now;
}
};
_throttleMethod.clear = () => {
lastCall = 0;
};
return _throttleMethod;
};
export { throttleMethod };
//# sourceMappingURL=throttleMethod.js.map