UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

20 lines 623 B
/** An iterator that concatenates other iterators together, in the order they are in the `iterators` arg. */ export class ConcatIterator { constructor(iterators) { this.iterators = iterators; } [Symbol.iterator]() { return this; } next(...args) { if (!this.iterators.length) return { done: true, value: undefined }; const next = this.iterators[0].next(...args); if (!next.done) return next; this.iterators.shift(); return this.next(...args); } } export default ConcatIterator; //# sourceMappingURL=ConcatIterator.js.map