UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

23 lines (21 loc) 674 B
import { AsyncIterableX } from '../asynciterable'; import { bindCallback } from '../util/bindcallback'; class FilterIterable 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++)) { yield item; } } } } export function filterAsync(source, predicate, thisArg) { return new FilterIterable(source, bindCallback(predicate, thisArg, 2)); } //# sourceMappingURL=filterasync.mjs.map