export function debounce void>( func: T, duration: number ): T { let timeout: ReturnType; return function (this: unknown, ...args) { clearTimeout(timeout); timeout = setTimeout(() => { func.apply(this, args); }, duration); } as T; }