mirror of https://github.com/fantasticit/think.git
10 lines
195 B
TypeScript
10 lines
195 B
TypeScript
|
export function debounce(func, timeout = 300) {
|
||
|
let timer;
|
||
|
return (...args) => {
|
||
|
clearTimeout(timer);
|
||
|
timer = setTimeout(() => {
|
||
|
func.apply(this, args);
|
||
|
}, timeout);
|
||
|
};
|
||
|
}
|