UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

25 lines (23 loc) 637 B
import { IterableX } from '../iterablex'; export class TakeWhileIterable extends IterableX { constructor(source, predicate) { super(); this._source = source; this._predicate = predicate; } *[Symbol.iterator]() { let i = 0; for (const item of this._source) { if (!this._predicate(item, i++)) { break; } yield item; } } } export function takeWhile(predicate) { return function takeWhileOperatorFunction(source) { return new TakeWhileIterable(source, predicate); }; } //# sourceMappingURL=takewhile.mjs.map