1 var arrayFilter = require('../internal/arrayFilter'),
2 arrayMap = require('../internal/arrayMap'),
3 baseProperty = require('../internal/baseProperty'),
4 isArrayLike = require('../internal/isArrayLike');
6 /* Native method references for those with the same name as other `lodash` methods. */
7 var nativeMax = Math.max;
10 * This method is like `_.zip` except that it accepts an array of grouped
11 * elements and creates an array regrouping the elements to their pre-zip
17 * @param {Array} array The array of grouped elements to process.
18 * @returns {Array} Returns the new array of regrouped elements.
21 * var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]);
22 * // => [['fred', 30, true], ['barney', 40, false]]
25 * // => [['fred', 'barney'], [30, 40], [true, false]]
27 function unzip(array) {
28 if (!(array && array.length)) {
34 array = arrayFilter(array, function(group) {
35 if (isArrayLike(group)) {
36 length = nativeMax(group.length, length);
40 var result = Array(length);
41 while (++index < length) {
42 result[index] = arrayMap(array, baseProperty(index));
47 module.exports = unzip;