mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
Ensure the result of _.difference is based on the values of the first param only. [#1038]
This commit is contained in:
@@ -4363,18 +4363,10 @@
|
||||
* _.difference([1, 2, 3], [4, 2]);
|
||||
* // => [1, 3]
|
||||
*/
|
||||
function difference() {
|
||||
var args = arguments,
|
||||
index = -1,
|
||||
length = args.length;
|
||||
|
||||
while (++index < length) {
|
||||
var value = args[index];
|
||||
if (isArray(value) || isArguments(value)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return baseDifference(value, baseFlatten(args, false, true, ++index));
|
||||
function difference(array) {
|
||||
return (isArray(array) || isArguments(array))
|
||||
? baseDifference(array, baseFlatten(arguments, false, true, 1))
|
||||
: [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5570,7 +5562,9 @@
|
||||
* // => [3]
|
||||
*/
|
||||
function without(array) {
|
||||
return baseDifference(array, baseSlice(arguments, 1));
|
||||
return (isArray(array) || isArguments(array))
|
||||
? baseDifference(array, baseSlice(arguments, 1))
|
||||
: [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user