_mapCacheSet.js 489 B

1234567891011121314151617181920212223
  1. var getMapData = require('./_getMapData');
  2. /**
  3. * Sets the map `key` to `value`.
  4. *
  5. * @private
  6. * @name set
  7. * @memberOf MapCache
  8. * @param {string} key The key of the value to set.
  9. * @param {*} value The value to set.
  10. * @returns {Object} Returns the map cache instance.
  11. */
  12. function mapCacheSet(key, value) {
  13. var data = getMapData(this, key),
  14. size = data.size;
  15. data.set(key, value);
  16. this.size += data.size == size ? 0 : 1;
  17. return this;
  18. }
  19. module.exports = mapCacheSet;