UNPKG

@sapphire/utilities

Version:
30 lines (27 loc) 634 B
'use strict'; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // src/lib/throttle.ts function throttle(func, wait) { let prev = 0; let prevValue; return Object.assign( (...args) => { const now = Date.now(); if (now - prev > wait) { prev = now; return prevValue = func(...args); } return prevValue; }, { flush() { prev = 0; } } ); } __name(throttle, "throttle"); exports.throttle = throttle; //# sourceMappingURL=throttle.cjs.map //# sourceMappingURL=throttle.cjs.map