mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 22:47:50 +00:00
27 lines
709 B
JavaScript
27 lines
709 B
JavaScript
define(['./_ListCache', './_MapCache'], function(ListCache, MapCache) {
|
|
|
|
/** Used as the size to enable large array optimizations. */
|
|
var LARGE_ARRAY_SIZE = 200;
|
|
|
|
/**
|
|
* Sets the stack `key` to `value`.
|
|
*
|
|
* @private
|
|
* @name set
|
|
* @memberOf Stack
|
|
* @param {string} key The key of the value to set.
|
|
* @param {*} value The value to set.
|
|
* @returns {Object} Returns the stack cache instance.
|
|
*/
|
|
function stackSet(key, value) {
|
|
var cache = this.__data__;
|
|
if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
|
|
cache = this.__data__ = new MapCache(cache.__data__);
|
|
}
|
|
cache.set(key, value);
|
|
return this;
|
|
}
|
|
|
|
return stackSet;
|
|
});
|