export function throttle void>( func: T, wait: number ): (...args: Parameters) => void { let inThrottle: boolean = false; let lastArgs: Parameters | null = null; return function (...args: Parameters) { if (!inThrottle) { func(...args); inThrottle = true; setTimeout(() => { inThrottle = false; if (lastArgs) { func(...lastArgs); lastArgs = null; } }, wait); } else { lastArgs = args; } }; }