Files
Tarokka/tools/throttle.ts
2025-07-04 13:59:57 -04:00

13 lines
223 B
TypeScript

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