Bug 1500735 - Update cached-iterable in Fluent to 0.3.0. r=stas

Differential Revision: https://phabricator.services.mozilla.com/D9350

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Zibi Braniecki 2018-10-22 15:05:35 +00:00
parent 9bfc0d1143
commit 403e3bbc2e

View File

@ -71,26 +71,6 @@ class CachedAsyncIterable extends CachedIterable {
}
}
/**
* Synchronous iterator over the cached elements.
*
* Return a generator object implementing the iterator protocol over the
* cached elements of the original (async or sync) iterable.
*/
[Symbol.iterator]() {
const cached = this;
let cur = 0;
return {
next() {
if (cached.length === cur) {
return {value: undefined, done: true};
}
return cached[cur++];
},
};
}
/**
* Asynchronous iterator caching the yielded elements.
*
@ -106,7 +86,7 @@ class CachedAsyncIterable extends CachedIterable {
return {
async next() {
if (cached.length <= cur) {
cached.push(await cached.iterator.next());
cached.push(cached.iterator.next());
}
return cached[cur++];
},
@ -123,10 +103,10 @@ class CachedAsyncIterable extends CachedIterable {
let idx = 0;
while (idx++ < count) {
const last = this[this.length - 1];
if (last && last.done) {
if (last && (await last).done) {
break;
}
this.push(await this.iterator.next());
this.push(this.iterator.next());
}
// Return the last cached {value, done} object to allow the calling
// code to decide if it needs to call touchNext again.