UNPKG

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