@pmwcs/base
Version:
PMWCS base module
15 lines (13 loc) • 329 B
JavaScript
export const debounce = function (func, wait) {
let timeout;
return function () {
const context = this;
const args = arguments;
const later = function () {
timeout = null;
func.apply(context, args);
};
timeout !== null && clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
};