b8f5d5e7ec74c1cc8c853aa31f2ed19ce23d2a17
[yaffs-website] / node_modules / grunt-legacy-util / node_modules / lodash / unzipWith.js
1 var apply = require('./_apply'),
2     arrayMap = require('./_arrayMap'),
3     unzip = require('./unzip');
4
5 /**
6  * This method is like `_.unzip` except that it accepts `iteratee` to specify
7  * how regrouped values should be combined. The iteratee is invoked with the
8  * elements of each group: (...group).
9  *
10  * @static
11  * @memberOf _
12  * @category Array
13  * @param {Array} array The array of grouped elements to process.
14  * @param {Function} [iteratee=_.identity] The function to combine regrouped values.
15  * @returns {Array} Returns the new array of regrouped elements.
16  * @example
17  *
18  * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
19  * // => [[1, 10, 100], [2, 20, 200]]
20  *
21  * _.unzipWith(zipped, _.add);
22  * // => [3, 30, 300]
23  */
24 function unzipWith(array, iteratee) {
25   if (!(array && array.length)) {
26     return [];
27   }
28   var result = unzip(array);
29   if (iteratee == null) {
30     return result;
31   }
32   return arrayMap(result, function(group) {
33     return apply(iteratee, undefined, group);
34   });
35 }
36
37 module.exports = unzipWith;