UNPKG

@resourge/react-fetch

Version:

[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

28 lines (26 loc) 616 B
/** * react-fetch v1.41.3 * * 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