export function debounce(func: (...args: any[]) => void, wait: number) { let timeout: ReturnType | null; return (...args: any[]) => { if (timeout) { clearTimeout(timeout); } timeout = setTimeout(() => { func(...args); }, wait); }; }