8
0

_stackSet.js 673 B

1234567891011121314151617181920212223242526
  1. import ListCache from './_ListCache';
  2. import MapCache from './_MapCache';
  3. /** Used as the size to enable large array optimizations. */
  4. var LARGE_ARRAY_SIZE = 200;
  5. /**
  6. * Sets the stack `key` to `value`.
  7. *
  8. * @private
  9. * @name set
  10. * @memberOf Stack
  11. * @param {string} key The key of the value to set.
  12. * @param {*} value The value to set.
  13. * @returns {Object} Returns the stack cache instance.
  14. */
  15. function stackSet(key, value) {
  16. var cache = this.__data__;
  17. if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
  18. cache = this.__data__ = new MapCache(cache.__data__);
  19. }
  20. cache.set(key, value);
  21. return this;
  22. }
  23. export default stackSet;