_hashGet.js 757 B

12345678910111213141516171819202122232425262728
  1. import nativeCreate from './_nativeCreate';
  2. /** Used to stand-in for `undefined` hash values. */
  3. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  4. /** Used for built-in method references. */
  5. var objectProto = Object.prototype;
  6. /** Used to check objects for own properties. */
  7. var hasOwnProperty = objectProto.hasOwnProperty;
  8. /**
  9. * Gets the hash value for `key`.
  10. *
  11. * @private
  12. * @param {Object} hash The hash to query.
  13. * @param {string} key The key of the value to get.
  14. * @returns {*} Returns the entry value.
  15. */
  16. function hashGet(hash, key) {
  17. if (nativeCreate) {
  18. var result = hash[key];
  19. return result === HASH_UNDEFINED ? undefined : result;
  20. }
  21. return hasOwnProperty.call(hash, key) ? hash[key] : undefined;
  22. }
  23. export default hashGet;