9 lines
190 B
TypeScript
9 lines
190 B
TypeScript
export function debounce<T extends Function>(cb: T, wait = 500) {
|
|
let h: any;
|
|
let callable = () => {
|
|
clearTimeout(h);
|
|
h = setTimeout(() => cb(), wait);
|
|
};
|
|
return callable;
|
|
}
|