From 723ab5c0527f46cab98cb53cb67641a2abb2456e Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 24 Jun 2015 00:25:01 +1000 Subject: [PATCH] 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. --- common/modules/base.jsm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/common/modules/base.jsm b/common/modules/base.jsm index abdd6b31..e7f37a01 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -1743,18 +1743,19 @@ update(iter, { }, /** - * Zips the contents of two arrays. The resulting array is the length of - * ary1, with any shortcomings of ary2 replaced with null strings. + * Zips the contents of two iterables. The resulting iterable is the length + * of iter1, with any shortcomings of iter2 replaced with null strings. * - * @param {Array} ary1 - * @param {Array} ary2 - * @returns {Array} + * @param {Iterable} iter1 + * @param {Iterable} iter2 + * @returns {Generator} */ zip: function* zip(iter1, iter2) { - try { - yield [iter1.next(), iter2.next()]; + let i = iter2[Symbol.iterator](); + for (let x of iter1) { + let y = i.next().value; + yield [x, y === undefined ? "" : y]; } - catch (e if e instanceof StopIteration) {} } });