mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Correct the resolution of length in _.zip.
This commit is contained in:
4
dist/lodash.underscore.js
vendored
4
dist/lodash.underscore.js
vendored
@@ -2026,8 +2026,8 @@
|
||||
*/
|
||||
function zip() {
|
||||
var index = -1,
|
||||
length = max(pluck(arguments, 'length')),
|
||||
result = Array(length < 0 ? 0 : length);
|
||||
length = isArray(length = max(arguments, 'length')) && length.length || 0,
|
||||
result = Array(length);
|
||||
|
||||
while (++index < length) {
|
||||
result[index] = pluck(arguments, index);
|
||||
|
||||
@@ -3833,7 +3833,7 @@
|
||||
function zip() {
|
||||
var array = arguments.length > 1 ? arguments : arguments[0],
|
||||
index = -1,
|
||||
length = (array && array.length) ? max(array, 'length').length : 0,
|
||||
length = isArray(length = max(array, 'length')) && length.length || 0,
|
||||
result = Array(length);
|
||||
|
||||
while (++index < length) {
|
||||
|
||||
15
test/test.js
15
test/test.js
@@ -10434,6 +10434,21 @@
|
||||
deepEqual(actual, [['barney', 36, undefined], ['fred', 40, false]]);
|
||||
});
|
||||
|
||||
test('should treat falsey values as empty arrays', 1, function() {
|
||||
var expected = _.map(falsey, _.constant([]));
|
||||
|
||||
var actual = _.map(falsey, function(value) {
|
||||
return _.zip(value, value, value);
|
||||
});
|
||||
|
||||
deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('should support consuming its return value', 1, function() {
|
||||
var expected = [['barney', 'fred'], [36, 40]];
|
||||
deepEqual(_.zip(_.zip(_.zip(_.zip(expected)))), expected);
|
||||
});
|
||||
|
||||
test('should support consuming its return value', 1, function() {
|
||||
var expected = [['barney', 'fred'], [36, 40]];
|
||||
deepEqual(_.zip(_.zip(_.zip(_.zip(expected)))), expected);
|
||||
|
||||
Reference in New Issue
Block a user