1 var restParam = require('../function/restParam'),
2 unzipWith = require('./unzipWith');
5 * This method is like `_.zip` except that it accepts an iteratee to specify
6 * how grouped values should be combined. The `iteratee` is bound to `thisArg`
7 * and invoked with four arguments: (accumulator, value, index, group).
12 * @param {...Array} [arrays] The arrays to process.
13 * @param {Function} [iteratee] The function to combine grouped values.
14 * @param {*} [thisArg] The `this` binding of `iteratee`.
15 * @returns {Array} Returns the new array of grouped elements.
18 * _.zipWith([1, 2], [10, 20], [100, 200], _.add);
21 var zipWith = restParam(function(arrays) {
22 var length = arrays.length,
23 iteratee = length > 2 ? arrays[length - 2] : undefined,
24 thisArg = length > 1 ? arrays[length - 1] : undefined;
26 if (length > 2 && typeof iteratee == 'function') {
29 iteratee = (length > 1 && typeof thisArg == 'function') ? (--length, thisArg) : undefined;
32 arrays.length = length;
33 return unzipWith(arrays, iteratee, thisArg);
36 module.exports = zipWith;