export function debounce( func: (...args: Params) => any, delay = 300 ) { let debounceTimer: ReturnType return function (this: U, ...args: Parameters) { const context = this clearTimeout(debounceTimer) debounceTimer = setTimeout(() => func.apply(context, args), delay) } }