debounce
unknown
javascript
5 years ago
267 B
8
Indexable
const debounce = (callback, delay = 1000) => {
let timeoutId;
return (...arg) => {
if (timeoutId) {
clearTimeout(timeoutId)
}
timeoutId = setTimeout(() => {
callback.apply(null, arg);
}, delay);
}
}Editor is loading...