1
0
forked from Rowland/EG
EG/Cesium-1.132/node_modules/glob-watcher/lib/debounce.js
2025-08-25 17:48:13 +08:00

27 lines
370 B
JavaScript

'use strict';
function debounce(fn, delay) {
var timeout;
var args;
var self;
return function () {
self = this;
args = arguments;
clear();
timeout = setTimeout(run, delay);
};
function run() {
clear();
fn.apply(self, args);
}
function clear() {
clearTimeout(timeout);
timeout = null;
}
}
module.exports = debounce;