src/lib/utils.ts (view raw)
1export const debounce = (callback: Function, wait = 300) => { 2 let timeout: ReturnType<typeof setTimeout>; 3 4 return (...args: any[]) => { 5 clearTimeout(timeout); 6 timeout = setTimeout(() => callback(...args), wait); 7 }; 8};