vendor: 2,908 bytes, lines 1-75
1(function(){ 2 var _ = {}; 3 _.now = Date.now || function(){ 4 return new Date().getTime(); 5 }; 6 // Returns a function, that, when invoked, will only be triggered at most once 7 // during a given window of time. Normally, the throttled function will run 8 // as much as it can, without ever going more than once per `wait` duration; 9 // but if you'd like to disable the execution on the leading edge, pass 10 // `{leading: false}`. To disable execution on the trailing edge, ditto. 11 _.throttle = function(func, wait, options) { 12 var context, args, result; 13 var timeout = null; 14 var previous = 0; 15 if (!options) options = {}; 16 var later = function() { 17 previous = options.leading === false ? 0 : _.now(); 18 timeout = null; 19 result = func.apply(context, args); 20 if (!timeout) context = args = null; 21 }; 22 return function() { 23 var now = _.now(); 24 if (!previous && options.leading === false) previous = now; 25 var remaining = wait - (now - previous); 26 context = this; 27 args = arguments; 28 if (remaining <= 0 || remaining > wait) { 29 if (timeout) { 30 clearTimeout(timeout); 31 timeout = null; 32 } 33 previous = now; 34 result = func.apply(context, args); 35 if (!timeout) context = args = null; 36 } else if (!timeout && options.trailing !== false) { 37 timeout = setTimeout(later, remaining); 38 } 39 return result; 40 }; 41 }; 42 // Returns a function, that, as long as it continues to be invoked, will not 43 // be triggered. The function will be called after it stops being called for 44 // N milliseconds. If `immediate` is passed, trigger the function on the 45 // leading edge, instead of the trailing. 46 _.debounce = function(func, wait, immediate) { 47 var timeout, args, context, timestamp, result; 48 var later = function() { 49 var last = _.now() - timestamp; 50 if (last < wait && last >= 0) { 51 timeout = setTimeout(later, wait - last); 52 } else { 53 timeout = null; 54 if (!immediate) { 55 result = func.apply(context, args); 56 if (!timeout) context = args = null; 57 } 58 } 59 }; 60 return function() { 61 context = this; 62 args = arguments; 63 timestamp = _.now(); 64 var callNow = immediate && !timeout; 65 if (!timeout) timeout = setTimeout(later, wait); 66 if (callNow) { 67 result = func.apply(context, args); 68 context = args = null; 69 } 70 return result; 71 }; 72 }; 73 74 window.EventUtils = _; 75}());
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.