Ensure the result of _.difference is based on the values of the first param only. [#1038]

This commit is contained in:
jdalton
2015-03-10 21:31:24 -07:00
parent 028234ba86
commit 56c5ebcb71
2 changed files with 19 additions and 20 deletions

View File

@@ -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))
: [];
}
/**