mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 23:37:49 +00:00
Ensure _.xor() returns new unique array.
This commit is contained in:
committed by
John-David Dalton
parent
c61a0cdd22
commit
64fc924357
@@ -5436,18 +5436,17 @@
|
||||
* // => [1, 4, 5]
|
||||
*/
|
||||
function xor() {
|
||||
var index = -1,
|
||||
var result,
|
||||
index = -1,
|
||||
length = arguments.length;
|
||||
|
||||
while (++index < length) {
|
||||
var array = arguments[index];
|
||||
if (isArray(array) || isArguments(array)) {
|
||||
var result = result
|
||||
? baseUniq(baseDifference(result, array).concat(baseDifference(array, result)))
|
||||
: array;
|
||||
result = result ? baseDifference(result, array).concat(baseDifference(array, result)) : array;
|
||||
}
|
||||
}
|
||||
return result || [];
|
||||
return result ? baseUniq(result) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8108,9 +8108,10 @@
|
||||
deepEqual(actual, [1, 4, 5]);
|
||||
});
|
||||
|
||||
test('should return an array of unique values', 1, function() {
|
||||
test('should return an array of unique values', 2, function() {
|
||||
var actual = _.xor([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]);
|
||||
deepEqual(actual, [1, 4, 5]);
|
||||
deepEqual(_.xor([1, 1]), [1]);
|
||||
});
|
||||
|
||||
test('should return a wrapped value when chaining', 2, function() {
|
||||
|
||||
Reference in New Issue
Block a user