source: trip-planner-front/node_modules/lodash/unzip.js@ bdd6491

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

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1var arrayFilter = require('./_arrayFilter'),
2 arrayMap = require('./_arrayMap'),
3 baseProperty = require('./_baseProperty'),
4 baseTimes = require('./_baseTimes'),
5 isArrayLikeObject = require('./isArrayLikeObject');
6
7/* Built-in method references for those with the same name as other `lodash` methods. */
8var nativeMax = Math.max;
9
10/**
11 * This method is like `_.zip` except that it accepts an array of grouped
12 * elements and creates an array regrouping the elements to their pre-zip
13 * configuration.
14 *
15 * @static
16 * @memberOf _
17 * @since 1.2.0
18 * @category Array
19 * @param {Array} array The array of grouped elements to process.
20 * @returns {Array} Returns the new array of regrouped elements.
21 * @example
22 *
23 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
24 * // => [['a', 1, true], ['b', 2, false]]
25 *
26 * _.unzip(zipped);
27 * // => [['a', 'b'], [1, 2], [true, false]]
28 */
29function unzip(array) {
30 if (!(array && array.length)) {
31 return [];
32 }
33 var length = 0;
34 array = arrayFilter(array, function(group) {
35 if (isArrayLikeObject(group)) {
36 length = nativeMax(group.length, length);
37 return true;
38 }
39 });
40 return baseTimes(length, function(index) {
41 return arrayMap(array, baseProperty(index));
42 });
43}
44
45module.exports = unzip;
Note: See TracBrowser for help on using the repository browser.