data-forge
Version:
JavaScript data transformation and analysis toolkit inspired by Pandas and LINQ.
44 lines • 1.57 kB
JavaScript
;
//
// An iterator that concatenates multiple iterables.
//
Object.defineProperty(exports, "__esModule", { value: true });
var ConcatIterator = /** @class */ (function () {
function ConcatIterator(iterables) {
this.curIterator = null;
this.iterables = iterables;
this.iterator = iterables[Symbol.iterator]();
this.moveToNextIterable();
}
//
// Move onto the next iterable.
//
ConcatIterator.prototype.moveToNextIterable = function () {
var nextIterable = this.iterator.next();
if (nextIterable.done) {
this.curIterator = null;
}
else {
this.curIterator = nextIterable.value[Symbol.iterator]();
}
};
ConcatIterator.prototype.next = function () {
// eslint-disable-next-line no-constant-condition
while (true) {
if (this.curIterator == null) {
// Finished iterating all sub-iterators.
// https://github.com/Microsoft/TypeScript/issues/8938
return { done: true }; // <= explicit cast here!;
}
var result = this.curIterator.next();
if (!result.done) {
return result; // Found a valid result from the current iterable.
}
// Find the next non empty iterable.
this.moveToNextIterable();
}
};
return ConcatIterator;
}());
exports.ConcatIterator = ConcatIterator;
//# sourceMappingURL=concat-iterator.js.map