unzip.js 464 B

123456789101112131415161718
  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. });