91faaf40f44245645d28566f5e094a5262ecef2c
[yaffs-website] / baseXor.js
1 var arrayPush = require('./arrayPush'),
2     baseDifference = require('./baseDifference'),
3     baseUniq = require('./baseUniq');
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 index = -1,
17       length = arrays.length;
18
19   while (++index < length) {
20     var result = result
21       ? arrayPush(
22           baseDifference(result, arrays[index], iteratee, comparator),
23           baseDifference(arrays[index], result, iteratee, comparator)
24         )
25       : arrays[index];
26   }
27   return (result && result.length) ? baseUniq(result, iteratee, comparator) : [];
28 }
29
30 module.exports = baseXor;