16 lines
No EOL
376 B
JavaScript
16 lines
No EOL
376 B
JavaScript
export function debounce(fn, time) {
|
|
var timerId = undefined;
|
|
return function () {
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
args[_key] = arguments[_key];
|
|
}
|
|
|
|
if (timerId) {
|
|
clearTimeout(timerId);
|
|
}
|
|
|
|
timerId = setTimeout(function () {
|
|
return fn.apply(void 0, args);
|
|
}, time);
|
|
};
|
|
} |