Sha256: 819a6c811a5e283f74a96a1e61188e456dbeb0720d381afd0062108318f191d2

Contents?: true

Size: 1.3 KB

Versions: 153

Compression:

Stored size: 1.3 KB

Contents

var arrayFilter = require('../internal/arrayFilter'),
    arrayMap = require('../internal/arrayMap'),
    baseProperty = require('../internal/baseProperty'),
    isArrayLike = require('../internal/isArrayLike');

/* Native method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;

/**
 * This method is like `_.zip` except that it accepts an array of grouped
 * elements and creates an array regrouping the elements to their pre-zip
 * configuration.
 *
 * @static
 * @memberOf _
 * @category Array
 * @param {Array} array The array of grouped elements to process.
 * @returns {Array} Returns the new array of regrouped elements.
 * @example
 *
 * var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]);
 * // => [['fred', 30, true], ['barney', 40, false]]
 *
 * _.unzip(zipped);
 * // => [['fred', 'barney'], [30, 40], [true, false]]
 */
function unzip(array) {
  if (!(array && array.length)) {
    return [];
  }
  var index = -1,
      length = 0;

  array = arrayFilter(array, function(group) {
    if (isArrayLike(group)) {
      length = nativeMax(group.length, length);
      return true;
    }
  });
  var result = Array(length);
  while (++index < length) {
    result[index] = arrayMap(array, baseProperty(index));
  }
  return result;
}

module.exports = unzip;

Version data entries

153 entries across 80 versions & 8 rubygems

Version Path
ilog-0.4.1 node_modules/contents/node_modules/lodash/array/unzip.js
ilog-0.4.1 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/array/unzip.js
ilog-0.4.1 node_modules/babel/node_modules/lodash/array/unzip.js
ilog-0.4.0 node_modules/babel/node_modules/lodash/array/unzip.js
ilog-0.4.0 node_modules/contents/node_modules/lodash/array/unzip.js
ilog-0.4.0 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/array/unzip.js
ilog-0.3.3 node_modules/babel/node_modules/lodash/array/unzip.js
ilog-0.3.3 node_modules/contents/node_modules/lodash/array/unzip.js
ilog-0.3.3 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/array/unzip.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/array/unzip.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/inquirer/node_modules/lodash/array/unzip.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/array/unzip.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/inquirer/node_modules/lodash/array/unzip.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/array/unzip.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/inquirer/node_modules/lodash/array/unzip.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/lodash/array/unzip.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/array/unzip.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/inquirer/node_modules/lodash/array/unzip.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/array/unzip.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/inquirer/node_modules/lodash/array/unzip.js