Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_stackSet.js 853B

12345678910111213141516171819202122232425262728293031323334
  1. var ListCache = require('./_ListCache'),
  2. Map = require('./_Map'),
  3. MapCache = require('./_MapCache');
  4. /** Used as the size to enable large array optimizations. */
  5. var LARGE_ARRAY_SIZE = 200;
  6. /**
  7. * Sets the stack `key` to `value`.
  8. *
  9. * @private
  10. * @name set
  11. * @memberOf Stack
  12. * @param {string} key The key of the value to set.
  13. * @param {*} value The value to set.
  14. * @returns {Object} Returns the stack cache instance.
  15. */
  16. function stackSet(key, value) {
  17. var data = this.__data__;
  18. if (data instanceof ListCache) {
  19. var pairs = data.__data__;
  20. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  21. pairs.push([key, value]);
  22. this.size = ++data.size;
  23. return this;
  24. }
  25. data = this.__data__ = new MapCache(pairs);
  26. }
  27. data.set(key, value);
  28. this.size = data.size;
  29. return this;
  30. }
  31. module.exports = stackSet;