mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
13 lines
292 B
TypeScript
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);
|
|
}
|
|
};
|
|
};
|