mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Ensure _.concat casts non-array array values to arrays.
This commit is contained in:
@@ -5855,7 +5855,7 @@
|
||||
*/
|
||||
var concat = rest(function(array, values) {
|
||||
if (!isArray(array)) {
|
||||
array = array == null ? [] : [Object(array)];
|
||||
array = array == null ? [] : [array];
|
||||
}
|
||||
values = baseFlatten(values, 1);
|
||||
return arrayConcat(array, values);
|
||||
|
||||
16
test/test.js
16
test/test.js
@@ -3096,6 +3096,22 @@
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('should cast non-array `array` values to arrays', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var values = [true, false, 1, NaN, 'a'];
|
||||
|
||||
var expected = lodashStable.map(values, function(value) {
|
||||
return [value, 2, [3]]
|
||||
});
|
||||
|
||||
var actual = lodashStable.map(values, function(value) {
|
||||
return _.concat(value, [2], [[3]]);
|
||||
});
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('should treat sparse arrays as dense', function(assert) {
|
||||
assert.expect(3);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user