UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

25 lines (23 loc) 730 B
import { AsyncIterableX } from '../asynciterablex'; export class FilterAsyncIterable extends AsyncIterableX { constructor(source, predicate, thisArg) { super(); this._source = source; this._predicate = predicate; this._thisArg = thisArg; } async *[Symbol.asyncIterator]() { let i = 0; for await (const item of this._source) { if (await this._predicate.call(this._thisArg, item, i++)) { yield item; } } } } export function filter(predicate, thisArg) { return function filterOperatorFunction(source) { return new FilterAsyncIterable(source, predicate, thisArg); }; } //# sourceMappingURL=filter.mjs.map