export function debounce(time: number, fn: (...a: unknown[]) => T) { let timer: ReturnType; return function (this: unknown) { const context = this; clearTimeout(timer); timer = setTimeout( () => fn.apply(context, (arguments as unknown) as unknown[]), time || 400 ); }; }