@razorpay/blade
Version:
The Design System that powers Razorpay
31 lines (28 loc) • 844 B
JavaScript
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
function throttle(func, wait) {
var isThrottled = false;
var lastArgs = null;
function wrapper() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (isThrottled) {
lastArgs = args;
return;
}
func.apply(void 0, args);
isThrottled = true;
setTimeout(function () {
isThrottled = false;
if (lastArgs) {
wrapper.apply(void 0, _toConsumableArray(lastArgs));
lastArgs = null;
}
}, wait);
}
return wrapper;
}
export { throttle as default };
//# sourceMappingURL=throttle.js.map