Files
console/src/lib/helpers/functions.ts
T
2022-10-11 14:10:12 +02:00

13 lines
292 B
TypeScript

export const throttle = (fn: () => void, delay: number) => {
let timeout = false;
return () => {
if (!timeout) {
timeout = true;
fn.apply(this);
setTimeout(() => {
timeout = false;
}, delay);
}
};
};