1 var baseSetData = require('./_baseSetData'),
2 now = require('./now');
4 /** Used to detect hot functions by number of calls within a span of milliseconds. */
9 * Sets metadata for `func`.
11 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
12 * period of time, it will trip its breaker and transition to an identity function
13 * to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070)
17 * @param {Function} func The function to associate metadata with.
18 * @param {*} data The metadata.
19 * @returns {Function} Returns `func`.
21 var setData = (function() {
25 return function(key, value) {
27 remaining = HOT_SPAN - (stamp - lastCalled);
31 if (++count >= HOT_COUNT) {
37 return baseSetData(key, value);
41 module.exports = setData;