Vencord/src/utils/debounce.ts

8 lines
254 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;
2022-09-16 16:59:34 -04:00
}