main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
851 bytes
|
Line | |
---|
1 | import ListCache from './_ListCache.js';
|
---|
2 | import Map from './_Map.js';
|
---|
3 | import MapCache from './_MapCache.js';
|
---|
4 |
|
---|
5 | /** Used as the size to enable large array optimizations. */
|
---|
6 | var LARGE_ARRAY_SIZE = 200;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Sets the stack `key` to `value`.
|
---|
10 | *
|
---|
11 | * @private
|
---|
12 | * @name set
|
---|
13 | * @memberOf Stack
|
---|
14 | * @param {string} key The key of the value to set.
|
---|
15 | * @param {*} value The value to set.
|
---|
16 | * @returns {Object} Returns the stack cache instance.
|
---|
17 | */
|
---|
18 | function stackSet(key, value) {
|
---|
19 | var data = this.__data__;
|
---|
20 | if (data instanceof ListCache) {
|
---|
21 | var pairs = data.__data__;
|
---|
22 | if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
---|
23 | pairs.push([key, value]);
|
---|
24 | this.size = ++data.size;
|
---|
25 | return this;
|
---|
26 | }
|
---|
27 | data = this.__data__ = new MapCache(pairs);
|
---|
28 | }
|
---|
29 | data.set(key, value);
|
---|
30 | this.size = data.size;
|
---|
31 | return this;
|
---|
32 | }
|
---|
33 |
|
---|
34 | export default stackSet;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.