1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.sdiff = sdiff;
|
7 |
|
8 | var _arrayFrom = require('array-from');
|
9 |
|
10 | var _arrayFrom2 = _interopRequireDefault(_arrayFrom);
|
11 |
|
12 | var _es6Set = require('es6-set');
|
13 |
|
14 | var _es6Set2 = _interopRequireDefault(_es6Set);
|
15 |
|
16 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17 |
|
18 | function sdiff(ours) {
|
19 | var _this = this;
|
20 |
|
21 | if (this.data.has(ours) && !(this.data.get(ours) instanceof _es6Set2.default)) {
|
22 | throw new Error('Key ' + ours + ' does not contain a set');
|
23 | }
|
24 |
|
25 | for (var _len = arguments.length, theirs = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
26 | theirs[_key - 1] = arguments[_key];
|
27 | }
|
28 |
|
29 | theirs.forEach(function (key) {
|
30 | if (_this.data.has(key) && !(_this.data.get(key) instanceof _es6Set2.default)) {
|
31 | throw new Error('Key ' + key + ' does not contain a set');
|
32 | }
|
33 | });
|
34 |
|
35 | var ourSet = this.data.has(ours) ? this.data.get(ours) : new _es6Set2.default();
|
36 | var theirSets = theirs.map(function (key) {
|
37 | return _this.data.has(key) ? _this.data.get(key) : new _es6Set2.default();
|
38 | });
|
39 | var difference = new _es6Set2.default((0, _arrayFrom2.default)(ourSet).filter(function (ourValue) {
|
40 | return theirSets.reduce(function (isUnique, set) {
|
41 | return set.has(ourValue) ? false : isUnique;
|
42 | },
|
43 | /* isUnique */true);
|
44 | }));
|
45 |
|
46 | return (0, _arrayFrom2.default)(difference);
|
47 | } |
\ | No newline at end of file |