mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Bump to v4.16.5.
This commit is contained in:
25
_baseXor.js
25
_baseXor.js
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayPush', './_baseDifference', './_baseUniq'], function(arrayPush, baseDifference, baseUniq) {
|
||||
define(['./_baseDifference', './_baseFlatten', './_baseUniq'], function(baseDifference, baseFlatten, baseUniq) {
|
||||
|
||||
/**
|
||||
* The base implementation of methods like `_.xor`, without support for
|
||||
@@ -11,18 +11,25 @@ define(['./_arrayPush', './_baseDifference', './_baseUniq'], function(arrayPush,
|
||||
* @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);
|
||||
}
|
||||
|
||||
return baseXor;
|
||||
|
||||
Reference in New Issue
Block a user