UNPKG

@sapphire/utilities

Version:
27 lines (25 loc) 530 B
import { __name } from '../chunk-PAWJFY3S.mjs'; // 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"); export { throttle }; //# sourceMappingURL=throttle.mjs.map //# sourceMappingURL=throttle.mjs.map