Ensure _.concat cases wraps nullish array values in an array.

This commit is contained in:
John-David Dalton
2016-03-28 17:44:13 -07:00
parent a7bf3352df
commit 3fe2efa311
2 changed files with 23 additions and 37 deletions

View File

@@ -5853,13 +5853,19 @@
* console.log(array);
* // => [1]
*/
var concat = rest(function(array, values) {
if (!isArray(array)) {
array = array == null ? [] : [array];
function concat() {
var length = arguments.length;
if (!length) {
return [];
}
values = baseFlatten(values, 1);
return arrayConcat(array, values);
});
var array = castArray(arguments[0]),
args = Array(length - 1);
while (length--) {
args[length - 1] = arguments[length];
}
return arrayConcat(array, baseFlatten(args, 1));
}
/**
* Creates an array of unique `array` values not included in the other given