|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const differenceWith = require('./differenceWith.js');
|
|---|
| 6 | const intersectionWith = require('./intersectionWith.js');
|
|---|
| 7 | const last = require('./last.js');
|
|---|
| 8 | const unionWith = require('./unionWith.js');
|
|---|
| 9 | const windowed = require('../../array/windowed.js');
|
|---|
| 10 | const isArrayLikeObject = require('../predicate/isArrayLikeObject.js');
|
|---|
| 11 |
|
|---|
| 12 | function xorWith(...values) {
|
|---|
| 13 | const lastValue = last.last(values);
|
|---|
| 14 | let comparator = (a, b) => a === b;
|
|---|
| 15 | if (typeof lastValue === 'function') {
|
|---|
| 16 | comparator = lastValue;
|
|---|
| 17 | values = values.slice(0, -1);
|
|---|
| 18 | }
|
|---|
| 19 | const arrays = values.filter(isArrayLikeObject.isArrayLikeObject);
|
|---|
| 20 | const union = unionWith.unionWith(...arrays, comparator);
|
|---|
| 21 | const intersections = windowed.windowed(arrays, 2).map(([arr1, arr2]) => intersectionWith.intersectionWith(arr1, arr2, comparator));
|
|---|
| 22 | return differenceWith.differenceWith(union, unionWith.unionWith(...intersections, comparator), comparator);
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | exports.xorWith = xorWith;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.