es6.map.js 642 B

12345678910111213141516171819
  1. 'use strict';
  2. var strong = require('./_collection-strong');
  3. var validate = require('./_validate-collection');
  4. var MAP = 'Map';
  5. // 23.1 Map Objects
  6. module.exports = require('./_collection')(MAP, function (get) {
  7. return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  8. }, {
  9. // 23.1.3.6 Map.prototype.get(key)
  10. get: function get(key) {
  11. var entry = strong.getEntry(validate(this, MAP), key);
  12. return entry && entry.v;
  13. },
  14. // 23.1.3.9 Map.prototype.set(key, value)
  15. set: function set(key, value) {
  16. return strong.def(validate(this, MAP), key === 0 ? 0 : key, value);
  17. }
  18. }, strong, true);