@reactivex/ix-esnext-esm
Version:
The Interactive Extensions for JavaScript
25 lines (23 loc) • 776 B
JavaScript
import { AsyncIterableX } from '../asynciterablex';
import { bindCallback } from '../../util/bindcallback';
export class FlatMapAsyncIterable extends AsyncIterableX {
constructor(source, selector) {
super();
this._source = source;
this._selector = selector;
}
async *[Symbol.asyncIterator]() {
for await (const outer of this._source) {
const inners = await this._selector(outer);
for await (const inner of inners) {
yield inner;
}
}
}
}
export function flatMap(selector, thisArg) {
return function flatMapOperatorFunction(source) {
return new FlatMapAsyncIterable(source, bindCallback(selector, thisArg, 1));
};
}
//# sourceMappingURL=flatmap.mjs.map