NeahNew/lib/utils/debounce.ts
2025-05-03 14:17:46 +02:00

11 lines
285 B
TypeScript

export function debounce<T extends (...args: any[]) => any>(
func: T,
wait: number
): (...args: Parameters<T>) => void {
let timeout: NodeJS.Timeout;
return (...args: Parameters<T>) => {
clearTimeout(timeout);
timeout = setTimeout(() => func(...args), wait);
};
}