UNPKG

data-forge-beta

Version:

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

34 lines 1.39 kB
"use strict"; // // Iterates an underlying iterable in the 'windows'. // Object.defineProperty(exports, "__esModule", { value: true }); var take_iterable_1 = require("../iterables/take-iterable"); var skip_iterable_1 = require("../iterables/skip-iterable"); var dataframe_1 = require("../dataframe"); var DataFrameWindowIterator = /** @class */ (function () { function DataFrameWindowIterator(columnNames, iterable, period) { this.windowIndex = 0; this.columnNames = columnNames; this.iterable = iterable; this.period = period; } DataFrameWindowIterator.prototype.next = function () { var window = new dataframe_1.DataFrame({ columnNames: this.columnNames, pairs: new take_iterable_1.TakeIterable(new skip_iterable_1.SkipIterable(this.iterable, this.windowIndex++ * this.period), this.period) }); if (window.none()) { // Nothing more to read from the underlying iterable. // https://github.com/Microsoft/TypeScript/issues/8938 return { done: true }; // <= explicit cast here!; } return { value: window, done: false, }; }; return DataFrameWindowIterator; }()); exports.DataFrameWindowIterator = DataFrameWindowIterator; //# sourceMappingURL=dataframe-window-iterator.js.map