Security update for permissions_by_term
[yaffs-website] / node_modules / uncss / node_modules / lodash / unzip.js
1 var arrayFilter = require('./internal/arrayFilter'),
2     arrayMap = require('./internal/arrayMap'),
3     baseProperty = require('./internal/baseProperty'),
4     baseTimes = require('./internal/baseTimes'),
5     isArrayLikeObject = require('./isArrayLikeObject');
6
7 /* Built-in method references for those with the same name as other `lodash` methods. */
8 var 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  * @category Array
18  * @param {Array} array The array of grouped elements to process.
19  * @returns {Array} Returns the new array of regrouped elements.
20  * @example
21  *
22  * var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]);
23  * // => [['fred', 30, true], ['barney', 40, false]]
24  *
25  * _.unzip(zipped);
26  * // => [['fred', 'barney'], [30, 40], [true, false]]
27  */
28 function unzip(array) {
29   if (!(array && array.length)) {
30     return [];
31   }
32   var length = 0;
33   array = arrayFilter(array, function(group) {
34     if (isArrayLikeObject(group)) {
35       length = nativeMax(group.length, length);
36       return true;
37     }
38   });
39   return baseTimes(length, function(index) {
40     return arrayMap(array, baseProperty(index));
41   });
42 }
43
44 module.exports = unzip;