1//http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ 2Function.prototype.debounce = function (threshold, execAsap) { 3 var func = this, // reference to original function 4 timeout; // handle to setTimeout async task (detection period) 5 // return the new debounced function which executes the original function only once 6 // until the detection period expires 7 return function debounced () { 8 var obj = this, // reference to original context object 9 args = arguments; // arguments at execution time 10 // this is the detection function. it will be executed if/when the threshold expires 11 function delayed () { 12 // if we're executing at the end of the detection period 13 if (!execAsap) 14 func.apply(obj, args); // execute now 15 // clear timeout handle 16 timeout = null; 17 }; 18 // stop any current detection period 19 if (timeout) 20 clearTimeout(timeout); 21 // otherwise, if we're not already waiting and we're executing at the beginning of the detection period 22 else if (execAsap) 23 func.apply(obj, args); // execute now 24 // reset the detection period 25 timeout = setTimeout(delayed, threshold || 100); 26 }; 27};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.