1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-25 08:46:25 +00:00
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;
}