mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-07 03:15:45 +01:00
Fix iter.zip.
This doesn't appear to be called anywhere but is presumably available for symmetry so the implementation roughly matches the slightly quirky Ary#zip. These might be better generalised at some point.
This commit is contained in:
@@ -1743,18 +1743,19 @@ update(iter, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zips the contents of two arrays. The resulting array is the length of
|
* Zips the contents of two iterables. The resulting iterable is the length
|
||||||
* ary1, with any shortcomings of ary2 replaced with null strings.
|
* of iter1, with any shortcomings of iter2 replaced with null strings.
|
||||||
*
|
*
|
||||||
* @param {Array} ary1
|
* @param {Iterable} iter1
|
||||||
* @param {Array} ary2
|
* @param {Iterable} iter2
|
||||||
* @returns {Array}
|
* @returns {Generator}
|
||||||
*/
|
*/
|
||||||
zip: function* zip(iter1, iter2) {
|
zip: function* zip(iter1, iter2) {
|
||||||
try {
|
let i = iter2[Symbol.iterator]();
|
||||||
yield [iter1.next(), iter2.next()];
|
for (let x of iter1) {
|
||||||
|
let y = i.next().value;
|
||||||
|
yield [x, y === undefined ? "" : y];
|
||||||
}
|
}
|
||||||
catch (e if e instanceof StopIteration) {}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user