iteragain
Version:
Javascript Iterable/Iterator/Generator-function utilities.
20 lines • 593 B
JavaScript
export class TeedIterator {
constructor(i, seekable, indices) {
this.i = i;
this.seekable = seekable;
this.indices = indices;
}
[Symbol.iterator]() {
return this;
}
next() {
const index = this.indices[this.i];
this.seekable.seek(index + 1);
if (index >= this.seekable.elements.length)
return { done: true, value: undefined };
this.indices[this.i]++;
return { done: false, value: this.seekable.elements[index] };
}
}
export default TeedIterator;
//# sourceMappingURL=TeedIterator.js.map