mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Move internal modules to “internal” folder.
This commit is contained in:
33
.internal/stackSet.js
Normal file
33
.internal/stackSet.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import ListCache from './.internal/ListCache.js';
|
||||
import MapCache from './.internal/MapCache.js';
|
||||
|
||||
/** Used as the size to enable large array optimizations. */
|
||||
const 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) {
|
||||
let data = this.__data__;
|
||||
if (data instanceof ListCache) {
|
||||
const pairs = data.__data__;
|
||||
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
||||
pairs.push([key, value]);
|
||||
this.size = ++data.size;
|
||||
return this;
|
||||
}
|
||||
data = this.__data__ = new MapCache(pairs);
|
||||
}
|
||||
data.set(key, value);
|
||||
this.size = data.size;
|
||||
return this;
|
||||
}
|
||||
|
||||
export default stackSet;
|
||||
Reference in New Issue
Block a user