esnext.set.union.js 750 B

12345678910111213141516171819
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var IS_PURE = require('../internals/is-pure');
  4. var getBuiltIn = require('../internals/get-built-in');
  5. var anObject = require('../internals/an-object');
  6. var aFunction = require('../internals/a-function');
  7. var speciesConstructor = require('../internals/species-constructor');
  8. var iterate = require('../internals/iterate');
  9. // `Set.prototype.union` method
  10. // https://github.com/tc39/proposal-set-methods
  11. $({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {
  12. union: function union(iterable) {
  13. var set = anObject(this);
  14. var newSet = new (speciesConstructor(set, getBuiltIn('Set')))(set);
  15. iterate(iterable, aFunction(newSet.add), { that: newSet });
  16. return newSet;
  17. }
  18. });