UNPKG

@reactivex/ix-es5-esm

Version:

The Interactive Extensions for JavaScript

40 lines (38 loc) 1.56 kB
import { __extends, __generator, __values } from "tslib"; import { IterableX } from './iterablex.js'; var WhileIterable = /** @class */ (function (_super) { __extends(WhileIterable, _super); function WhileIterable(condition, source) { var _this = _super.call(this) || this; _this._condition = condition; _this._source = source; return _this; } WhileIterable.prototype[Symbol.iterator] = function () { return __generator(this, function (_a) { switch (_a.label) { case 0: if (!this._condition()) return [3 /*break*/, 2]; return [5 /*yield**/, __values(this._source)]; case 1: _a.sent(); return [3 /*break*/, 0]; case 2: return [2 /*return*/]; } }); }; return WhileIterable; }(IterableX)); /** * Repeats the given source as long as the specified conditions holds, where * the condition is evaluated before each repeated source is iterated. * * @template TSource * @param {Iterable<TSource>} source Source to repeat as long as the condition function evaluates to true. * @param {((signal?: AbortSignal) => boolean)} condition Condition that will be evaluated before the source sequence is iterated. * @returns {IterableX<TSource>} An iterable which is repeated while the condition returns true. */ export function whileDo(source, condition) { return new WhileIterable(condition, source); } //# sourceMappingURL=whiledo.js.map