source: trip-planner-front/node_modules/lodash/unzipWith.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1var 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 * @since 3.8.0
13 * @category Array
14 * @param {Array} array The array of grouped elements to process.
15 * @param {Function} [iteratee=_.identity] The function to combine
16 * regrouped values.
17 * @returns {Array} Returns the new array of regrouped elements.
18 * @example
19 *
20 * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
21 * // => [[1, 10, 100], [2, 20, 200]]
22 *
23 * _.unzipWith(zipped, _.add);
24 * // => [3, 30, 300]
25 */
26function unzipWith(array, iteratee) {
27 if (!(array && array.length)) {
28 return [];
29 }
30 var result = unzip(array);
31 if (iteratee == null) {
32 return result;
33 }
34 return arrayMap(result, function(group) {
35 return apply(iteratee, undefined, group);
36 });
37}
38
39module.exports = unzipWith;
Note: See TracBrowser for help on using the repository browser.