blob: 2e0801243bebd28b3b4c7c867570b8cec52d0d3a (
plain)
1
2
3
4
5
6
7
8
9
10
|
export function debounce(fn, delay) {
let timeout = null;
return (...args) => {
if (timeout) clearTimeout(timeout);
timeout = setTimeout(() => {
timeout = null;
fn.apply(null, args);
}, delay||500);
}
}
|