debounce.js
export function debounce(fn, wait = 250) {
let timer = null;
return function debounced(...args) {
clearTimeout(timer);
timer = setTimeout(() => {
timer = null;
fn.apply(this, args);
}, wait);
};
}
export function debounce(fn, wait = 250) {
let timer = null;
return function debounced(...args) {
clearTimeout(timer);
timer = setTimeout(() => {
timer = null;
fn.apply(this, args);
}, wait);
};
}