UNPKG

583 BJavaScriptView Raw
1'use strict';
2var aSet = require('../internals/a-set');
3var add = require('../internals/set-helpers').add;
4var clone = require('../internals/set-clone');
5var getSetRecord = require('../internals/get-set-record');
6var iterateSimple = require('../internals/iterate-simple');
7
8// `Set.prototype.union` method
9// https://github.com/tc39/proposal-set-methods
10module.exports = function union(other) {
11 var O = aSet(this);
12 var keysIter = getSetRecord(other).getIterator();
13 var result = clone(O);
14 iterateSimple(keysIter, function (it) {
15 add(result, it);
16 });
17 return result;
18};