UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

27 lines (25 loc) 681 B
import { AsyncIterableX } from '../asynciterablex'; export class TakeAsyncIterable extends AsyncIterableX { constructor(source, count) { super(); this._source = source; this._count = count; } async *[Symbol.asyncIterator]() { let i = this._count; if (i > 0) { for await (const item of this._source) { yield item; if (--i === 0) { break; } } } } } export function take(count) { return function takeOperatorFunction(source) { return new TakeAsyncIterable(source, count); }; } //# sourceMappingURL=take.mjs.map