Sha256: 56591e928db4544765456b4a763ec56559a14502062a982d8a80dee07bdafa7e
Contents?: true
Size: 795 Bytes
Versions: 69
Compression:
Stored size: 795 Bytes
Contents
/** * Debounce callback execution */ function debounce(fn, threshold, isAsap){ var timeout, result; function debounced(){ var args = arguments, context = this; function delayed(){ if (! isAsap) { result = fn.apply(context, args); } timeout = null; } if (timeout) { clearTimeout(timeout); } else if (isAsap) { result = fn.apply(context, args); } timeout = setTimeout(delayed, threshold); return result; } debounced.cancel = function(){ clearTimeout(timeout); }; return debounced; } module.exports = debounce;
Version data entries
69 entries across 69 versions & 2 rubygems