aboutsummaryrefslogtreecommitdiff
path: root/src/utils/debounce.ts
blob: f001b7ba4fb62b715ee191da8ecaebd9de258307 (plain)
1
2
3
4
5
6
7
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;
}