unzip.js 462 B

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