unzip.js 454 B

123456789101112131415
  1. import max from './max.js';
  2. import getLength from './_getLength.js';
  3. import pluck from './pluck.js';
  4. // Complement of zip. Unzip accepts an array of arrays and groups
  5. // each array's elements on shared indices.
  6. export default function unzip(array) {
  7. var length = array && max(array, getLength).length || 0;
  8. var result = Array(length);
  9. for (var index = 0; index < length; index++) {
  10. result[index] = pluck(array, index);
  11. }
  12. return result;
  13. }