UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

24 lines 770 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConcatIterator = void 0; /** An iterator that concatenates other iterators together, in the order they are in the `iterators` arg. */ 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); } } exports.ConcatIterator = ConcatIterator; exports.default = ConcatIterator; //# sourceMappingURL=ConcatIterator.js.map