main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
740 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var aSet = require('../internals/a-set');
|
---|
3 | var SetHelpers = require('../internals/set-helpers');
|
---|
4 | var clone = require('../internals/set-clone');
|
---|
5 | var getSetRecord = require('../internals/get-set-record');
|
---|
6 | var iterateSimple = require('../internals/iterate-simple');
|
---|
7 |
|
---|
8 | var add = SetHelpers.add;
|
---|
9 | var has = SetHelpers.has;
|
---|
10 | var remove = SetHelpers.remove;
|
---|
11 |
|
---|
12 | // `Set.prototype.symmetricDifference` method
|
---|
13 | // https://github.com/tc39/proposal-set-methods
|
---|
14 | module.exports = function symmetricDifference(other) {
|
---|
15 | var O = aSet(this);
|
---|
16 | var keysIter = getSetRecord(other).getIterator();
|
---|
17 | var result = clone(O);
|
---|
18 | iterateSimple(keysIter, function (e) {
|
---|
19 | if (has(O, e)) remove(result, e);
|
---|
20 | else add(result, e);
|
---|
21 | });
|
---|
22 | return result;
|
---|
23 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.