UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

17 lines 720 B
import spy from './spy'; import tee from './tee'; import map from './map'; /** * The inverse of `zip` and `zipLongest`. This function disaggregates the elements of the input iterator. The nth * iterator in the returned tuple contains the nth element of each value in the input iterator. The length of the * returned tuple is determined by the length of the first value in the input iterator. */ export function unzip(arg) { var _a = spy(arg), head = _a[0][0], it = _a[1]; var n = Array.isArray(head) ? head.length : 1; if (n < 2) return [it]; return tee(it, n).map(function (it, i) { return map(it, function (v) { return v[i]; }); }); } export default unzip; //# sourceMappingURL=unzip.js.map