Vencord/src/utils/debounce.ts

7 lines
253 B
TypeScript
Raw Normal View History

export function debounce<T extends Function>(func: T, delay = 300): T {
let timeout: NodeJS.Timeout;
return function (...args: any[]) {
clearTimeout(timeout);
timeout = setTimeout(() => { func(...args); }, delay);
} as any;
}