1 /** Used to detect hot functions by number of calls within a span of milliseconds. */
5 /* Built-in method references for those with the same name as other `lodash` methods. */
6 var nativeNow = Date.now;
9 * Creates a function that'll short out and invoke `identity` instead
10 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
14 * @param {Function} func The function to restrict.
15 * @returns {Function} Returns the new shortable function.
17 function shortOut(func) {
22 var stamp = nativeNow(),
23 remaining = HOT_SPAN - (stamp - lastCalled);
27 if (++count >= HOT_COUNT) {
33 return func.apply(undefined, arguments);
37 module.exports = shortOut;