UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

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