1 var arrayMap = require('../internal/arrayMap'),
2 arrayReduce = require('../internal/arrayReduce'),
3 bindCallback = require('../internal/bindCallback'),
4 unzip = require('./unzip');
7 * This method is like `_.unzip` except that it accepts an iteratee to specify
8 * how regrouped values should be combined. The `iteratee` is bound to `thisArg`
9 * and invoked with four arguments: (accumulator, value, index, group).
14 * @param {Array} array The array of grouped elements to process.
15 * @param {Function} [iteratee] The function to combine regrouped values.
16 * @param {*} [thisArg] The `this` binding of `iteratee`.
17 * @returns {Array} Returns the new array of regrouped elements.
20 * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
21 * // => [[1, 10, 100], [2, 20, 200]]
23 * _.unzipWith(zipped, _.add);
26 function unzipWith(array, iteratee, thisArg) {
27 var length = array ? array.length : 0;
31 var result = unzip(array);
32 if (iteratee == null) {
35 iteratee = bindCallback(iteratee, thisArg, 4);
36 return arrayMap(result, function(group) {
37 return arrayReduce(group, iteratee, undefined, true);
41 module.exports = unzipWith;