export const debounce = any>( func: F, delay: number ): ((...args: Parameters) => void) => { let timeoutId: ReturnType | null; return function debounced(...args: Parameters) { if (timeoutId) { clearTimeout(timeoutId); } timeoutId = setTimeout(() => { func(...args); timeoutId = null; }, delay); }; };