Files
Tarokka/tools/throttle.ts
2025-06-28 20:16:52 -04:00

13 lines
231 B
TypeScript

export default function throttle(func: Function, threshold: number) {
let lastCall = 0;
return (...args: any[]) => {
const now = Date.now();
if (now - lastCall >= threshold) {
lastCall = now;
func(...args);
}
};
}