_hashSet.js 598 B

123456789101112131415161718192021222324
  1. var nativeCreate = require('./_nativeCreate');
  2. /** Used to stand-in for `undefined` hash values. */
  3. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  4. /**
  5. * Sets the hash `key` to `value`.
  6. *
  7. * @private
  8. * @name set
  9. * @memberOf Hash
  10. * @param {string} key The key of the value to set.
  11. * @param {*} value The value to set.
  12. * @returns {Object} Returns the hash instance.
  13. */
  14. function hashSet(key, value) {
  15. var data = this.__data__;
  16. this.size += this.has(key) ? 0 : 1;
  17. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  18. return this;
  19. }
  20. module.exports = hashSet;