main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | import baseDifference from './_baseDifference.js';
|
---|
2 | import baseFlatten from './_baseFlatten.js';
|
---|
3 | import baseUniq from './_baseUniq.js';
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * The base implementation of methods like `_.xor`, without support for
|
---|
7 | * iteratee shorthands, that accepts an array of arrays to inspect.
|
---|
8 | *
|
---|
9 | * @private
|
---|
10 | * @param {Array} arrays The arrays to inspect.
|
---|
11 | * @param {Function} [iteratee] The iteratee invoked per element.
|
---|
12 | * @param {Function} [comparator] The comparator invoked per element.
|
---|
13 | * @returns {Array} Returns the new array of values.
|
---|
14 | */
|
---|
15 | function baseXor(arrays, iteratee, comparator) {
|
---|
16 | var length = arrays.length;
|
---|
17 | if (length < 2) {
|
---|
18 | return length ? baseUniq(arrays[0]) : [];
|
---|
19 | }
|
---|
20 | var index = -1,
|
---|
21 | result = Array(length);
|
---|
22 |
|
---|
23 | while (++index < length) {
|
---|
24 | var array = arrays[index],
|
---|
25 | othIndex = -1;
|
---|
26 |
|
---|
27 | while (++othIndex < length) {
|
---|
28 | if (othIndex != index) {
|
---|
29 | result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
|
---|
30 | }
|
---|
31 | }
|
---|
32 | }
|
---|
33 | return baseUniq(baseFlatten(result, 1), iteratee, comparator);
|
---|
34 | }
|
---|
35 |
|
---|
36 | export default baseXor;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.