Chrome | 91.0.4472 | inherited | function | function(options) {
if (typeof options === 'number') options = {min:options, max:options*2};
var fn = this,
inst,
args,
timerMin = 0,
timerMax = 0,
triggered = true,
trigger = function() {
triggered = true;
clearTimeout( timerMax );
clearTimeout( timerMin );
timerMax = 0;
fn.apply(inst,args);
};
var wrapped = function() {
inst !== this && !triggered && trigger();
triggered = false;
inst = this;
args = arguments;
clearTimeout(timerMin);
timerMin = setTimeout(trigger, options.min);
!timerMax && options.max && (timerMax = setTimeout(trigger, options.max));
};
wrapped.trigger = function(){
args = arguments;
trigger();
};
return wrapped;
} |