File size: 294 Bytes
6f0655f
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
export function debounce<F extends (...args: any[]) => any>(
  func: F,
  waitFor: number,
): (...args: Parameters<F>) => void {
  let timeoutId: number;
  return (...args: Parameters<F>) => {
    clearTimeout(timeoutId);
    timeoutId = window.setTimeout(() => func(...args), waitFor);
  };
}