@amaui/utils
Version:
13 lines (12 loc) • 383 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const debounce = (method_, delay = 140) => {
let timeoutId;
function method(...args) {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => method_.apply(this, args), delay);
}
method.clear = () => clearTimeout(timeoutId);
return method;
};
exports.default = debounce;