@uploadcare/blocks
Version:
Building blocks for Uploadcare products integration
17 lines (16 loc) • 340 B
JavaScript
/**
* @param {function} callback
* @param {Number} wait
* @returns {function}
*/
export function debounce(callback, wait) {
let timer;
let debounced = (...args) => {
clearTimeout(timer);
timer = setTimeout(() => callback(...args), wait);
};
debounced.cancel = () => {
clearTimeout(timer);
};
return debounced;
}