UNPKG

react-lite-misc

Version:
27 lines (24 loc) 620 B
(function() { var slice = [].slice; module.exports = function(func, threshold, execAsap) { var timeout; timeout = null; return function() { var args, delayed, obj; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; obj = this; delayed = function() { if (!execAsap) { func.apply(obj, args); } return timeout = null; }; if (timeout) { clearTimeout(timeout); } else if (execAsap) { func.apply(obj, args); } return timeout = setTimeout(delayed, threshold || 100); }; }; }).call(this);