mapGet.js 555 B

1234567891011121314151617181920212223
  1. import Map from './Map';
  2. import assocGet from './assocGet';
  3. import hashGet from './hashGet';
  4. import isKeyable from './isKeyable';
  5. /**
  6. * Gets the map value for `key`.
  7. *
  8. * @private
  9. * @name get
  10. * @memberOf MapCache
  11. * @param {string} key The key of the value to get.
  12. * @returns {*} Returns the entry value.
  13. */
  14. function mapGet(key) {
  15. var data = this.__data__;
  16. if (isKeyable(key)) {
  17. return hashGet(typeof key == 'string' ? data.string : data.hash, key);
  18. }
  19. return Map ? data.map.get(key) : assocGet(data.map, key);
  20. }
  21. export default mapGet;