export const randomId = () => Math.random().toString(36).slice(2); export function debounce any>(fn: T, delay: number) { let timestamp: ReturnType; return function (this: any, ...args: Parameters) { if (timestamp) { clearTimeout(timestamp); } timestamp = setTimeout(() => { fn.apply(this, args); }, delay); }; }