export function debounce(func: Function, delay = 300) { let debounceTimer: ReturnType return function () { // @ts-expect-error this in TypeScript const context = this const args = arguments clearTimeout(debounceTimer) debounceTimer = setTimeout(() => func.apply(context, args), delay) } }