Files
terminal/web/src/utils/debounce.ts
T

9 lines
258 B
TypeScript

export function debounce<T extends Function>(cb: T, wait = 20) {
let h: number;
let callable = (...args: any) => {
clearTimeout(h);
// @ts-ignore
h = setTimeout(() => cb(...args), wait);
};
return <T>(<any>callable);
}