mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Bump to v4.16.5.
This commit is contained in:
25
_baseXor.js
25
_baseXor.js
@@ -1,5 +1,5 @@
|
||||
import arrayPush from './_arrayPush.js';
|
||||
import baseDifference from './_baseDifference.js';
|
||||
import baseFlatten from './_baseFlatten.js';
|
||||
import baseUniq from './_baseUniq.js';
|
||||
|
||||
/**
|
||||
@@ -13,18 +13,25 @@ import baseUniq from './_baseUniq.js';
|
||||
* @returns {Array} Returns the new array of values.
|
||||
*/
|
||||
function baseXor(arrays, iteratee, comparator) {
|
||||
var length = arrays.length;
|
||||
if (length < 2) {
|
||||
return length ? baseUniq(arrays[0]) : [];
|
||||
}
|
||||
var index = -1,
|
||||
length = arrays.length;
|
||||
result = Array(length);
|
||||
|
||||
while (++index < length) {
|
||||
var result = result
|
||||
? arrayPush(
|
||||
baseDifference(result, arrays[index], iteratee, comparator),
|
||||
baseDifference(arrays[index], result, iteratee, comparator)
|
||||
)
|
||||
: arrays[index];
|
||||
var array = arrays[index],
|
||||
othIndex = -1;
|
||||
|
||||
while (++othIndex < length) {
|
||||
var othArray = arrays[othIndex];
|
||||
if (othArray !== array) {
|
||||
result[index] = baseDifference(result[index] || array, othArray, iteratee, comparator);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (result && result.length) ? baseUniq(result, iteratee, comparator) : [];
|
||||
return baseUniq(baseFlatten(result, 1), iteratee, comparator);
|
||||
}
|
||||
|
||||
export default baseXor;
|
||||
|
||||
Reference in New Issue
Block a user