From 81b1d6e45189551e24c5a1d551ed384a1a947169 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 6 Jan 2016 23:26:02 -0800 Subject: [PATCH] Change arguments passed to `_.zipWith` and `_.unzipWith`. --- lodash.js | 6 ++++-- test/test.js | 27 +++++++++++++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/lodash.js b/lodash.js index 91ae02efa..138b4b066 100644 --- a/lodash.js +++ b/lodash.js @@ -6790,7 +6790,7 @@ return result; } return arrayMap(result, function(group) { - return arrayReduce(group, iteratee, undefined, true); + return apply(iteratee, undefined, group); }); } @@ -6947,7 +6947,9 @@ * @returns {Array} Returns the new array of grouped elements. * @example * - * _.zipWith([1, 2], [10, 20], [100, 200], _.add); + * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { + * return a + b + c; + * }); * // => [111, 222] */ var zipWith = rest(function(arrays) { diff --git a/test/test.js b/test/test.js index bd166d750..190bf25db 100644 --- a/test/test.js +++ b/test/test.js @@ -21839,7 +21839,12 @@ assert.expect(1); var array = [[1, 4], [2, 5], [3, 6]]; - assert.deepEqual(_.unzipWith(array, _.add), [6, 15]); + + var actual = _.unzipWith(array, function(a, b, c) { + return a + b + c; + }); + + assert.deepEqual(actual, [6, 15]); }); QUnit.test('should provide the correct `iteratee` arguments', function(assert) { @@ -21851,7 +21856,7 @@ args || (args = slice.call(arguments)); }); - assert.deepEqual(args, [1, 2, 1, [1, 2]]); + assert.deepEqual(args, [1, 2]); }); QUnit.test('should perform a basic unzip when `iteratee` is nullish', function(assert) { @@ -22218,10 +22223,20 @@ assert.expect(2); var array1 = [1, 2, 3], - array2 = [4, 5, 6]; + array2 = [4, 5, 6], + array3 = [7, 8, 9]; - assert.deepEqual(_.zipWith(array1, array2, _.add), [5, 7, 9]); - assert.deepEqual(_.zipWith(array1, [], _.add), [1, 2, 3]); + var actual = _.zipWith(array1, array2, array3, function(a, b, c) { + return a + b + c; + }); + + assert.deepEqual(actual, [12, 15, 18]); + + var actual = _.zipWith(array1, [], function(a, b) { + return a + (b || 0); + }); + + assert.deepEqual(actual, [1, 2, 3]); }); QUnit.test('should provide the correct `iteratee` arguments', function(assert) { @@ -22233,7 +22248,7 @@ args || (args = slice.call(arguments)); }); - assert.deepEqual(args, [1, 3, 1, [1, 3, 5]]); + assert.deepEqual(args, [1, 3, 5]); }); QUnit.test('should perform a basic zip when `iteratee` is nullish', function(assert) {