esnext.map.merge.js 699 B

123456789101112131415161718192021
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var IS_PURE = require('../internals/is-pure');
  4. var anObject = require('../internals/an-object');
  5. var aFunction = require('../internals/a-function');
  6. var iterate = require('../internals/iterate');
  7. // `Map.prototype.merge` method
  8. // https://github.com/tc39/proposal-collection-methods
  9. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  10. // eslint-disable-next-line no-unused-vars
  11. merge: function merge(iterable /* ...iterbles */) {
  12. var map = anObject(this);
  13. var setter = aFunction(map.set);
  14. var i = 0;
  15. while (i < arguments.length) {
  16. iterate(arguments[i++], setter, map, true);
  17. }
  18. return map;
  19. }
  20. });