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.

_listCacheSet.js 553B

1234567891011121314151617181920212223242526
  1. var assocIndexOf = require('./_assocIndexOf');
  2. /**
  3. * Sets the list cache `key` to `value`.
  4. *
  5. * @private
  6. * @name set
  7. * @memberOf ListCache
  8. * @param {string} key The key of the value to set.
  9. * @param {*} value The value to set.
  10. * @returns {Object} Returns the list cache instance.
  11. */
  12. function listCacheSet(key, value) {
  13. var data = this.__data__,
  14. index = assocIndexOf(data, key);
  15. if (index < 0) {
  16. ++this.size;
  17. data.push([key, value]);
  18. } else {
  19. data[index][1] = value;
  20. }
  21. return this;
  22. }
  23. module.exports = listCacheSet;