This commit is contained in:
Akhilesh Rangani
2024-06-14 16:56:47 +00:00
parent e5a36a4626
commit bd33eb9b1c
7 changed files with 300 additions and 796 deletions

View File

@ -61,3 +61,13 @@ export function addNew(
])
}
}
export function debounce<T extends (...args: any[]) => void>(func: T, wait: number): T {
let timeout: NodeJS.Timeout | null = null;
return function (...args: Parameters<T>) {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => func(...args), wait);
} as T;
}