2016-11-03 01:33:53 +01:00
|
|
|
var baseDifference = require('./_baseDifference'),
|
|
|
|
baseFlatten = require('./_baseFlatten'),
|
2016-10-10 03:43:44 +02:00
|
|
|
baseUniq = require('./_baseUniq');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The base implementation of methods like `_.xor`, without support for
|
|
|
|
* iteratee shorthands, that accepts an array of arrays to inspect.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {Array} arrays The arrays to inspect.
|
|
|
|
* @param {Function} [iteratee] The iteratee invoked per element.
|
|
|
|
* @param {Function} [comparator] The comparator invoked per element.
|
|
|
|
* @returns {Array} Returns the new array of values.
|
|
|
|
*/
|
|
|
|
function baseXor(arrays, iteratee, comparator) {
|
2016-11-03 01:33:53 +01:00
|
|
|
var length = arrays.length;
|
|
|
|
if (length < 2) {
|
|
|
|
return length ? baseUniq(arrays[0]) : [];
|
|
|
|
}
|
2016-10-10 03:43:44 +02:00
|
|
|
var index = -1,
|
2016-11-03 01:33:53 +01:00
|
|
|
result = Array(length);
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
while (++index < length) {
|
2016-11-03 01:33:53 +01:00
|
|
|
var array = arrays[index],
|
|
|
|
othIndex = -1;
|
|
|
|
|
|
|
|
while (++othIndex < length) {
|
|
|
|
if (othIndex != index) {
|
|
|
|
result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
|
|
|
|
}
|
|
|
|
}
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
2016-11-03 01:33:53 +01:00
|
|
|
return baseUniq(baseFlatten(result, 1), iteratee, comparator);
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = baseXor;
|