diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 8b702b844..04b370aa4 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -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); diff --git a/lodash.js b/lodash.js index 3bad12869..97c4bba9e 100644 --- a/lodash.js +++ b/lodash.js @@ -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) { diff --git a/test/test.js b/test/test.js index 919f7d57b..a1a04bf0f 100644 --- a/test/test.js +++ b/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);