UNPKG

data-forge

Version:

JavaScript data transformation and analysis toolkit inspired by Pandas and LINQ.

43 lines 1.53 kB
"use strict"; // // An iterator that iterates the elements of an iterable multiple times. // Implementation similar to - https://numpy.org/doc/stable/reference/generated/numpy.tile.html // Object.defineProperty(exports, "__esModule", { value: true }); var TileIterator = /** @class */ (function () { function TileIterator(iterable, count) { this.count = 0; this.repetition = 0; this.firstIteration = true; this.iterable = iterable; this.iterator = iterable[Symbol.iterator](); this.count = count; } TileIterator.prototype.next = function () { var result = this.iterator.next(); // Return done for empty iterable if (this.firstIteration && result.done) { return { done: true }; } this.firstIteration = false; if (result.done) { this.repetition += 1; // Reinitialize iterator once iterated completely this.iterator = this.iterable[Symbol.iterator](); result = this.iterator.next(); } if (this.repetition < this.count) { return { done: false, value: result.value, }; } else { // https://github.com/Microsoft/TypeScript/issues/8938 return { done: true }; // <= explicit cast here!; } }; return TileIterator; }()); exports.TileIterator = TileIterator; //# sourceMappingURL=tile-iterator.js.map