4 * Debounce callback execution
6 function debounce(fn, threshold, isAsap){
9 var args = arguments, context = this;
12 result = fn.apply(context, args);
17 clearTimeout(timeout);
19 result = fn.apply(context, args);
21 timeout = setTimeout(delayed, threshold);
24 debounced.cancel = function(){
25 clearTimeout(timeout);
30 module.exports = debounce;