UNPKG

@mozaic-ds/vue

Version:

Mozaic-Vue is the Vue.js implementation of ADEO Design system

16 lines (14 loc) 397 B
export function debounce<T extends (...args: unknown[]) => unknown>( fn: T, wait: number, ): (...args: Parameters<T>) => void { let timeoutId: ReturnType<typeof setTimeout> | null = null; return function (this: unknown, ...args: Parameters<T>) { if (timeoutId) { clearTimeout(timeoutId); } timeoutId = setTimeout(() => { fn.apply(this, args); }, wait); }; }