searching the web…
function debounce<F extends (...args: any[]) => any>(
func: F,
waitFor: number,
): (...args: Parameters<F>) => void {
let timeout: ReturnType<typeof setTimeout>;
return (...args: Parameters<F>): void => {
clearTimeout(timeout);
timeout = setTimeout(() => func(...args), waitFor);
};
}Debounce delays function execution until after a specified delay has passed since the last call; widely used for search input, autosave, and resize handlers.