dist/async-iterable/operators.js
/** Yield all items in every iterable returned by the mapper when applied to every item in the source iterable */
Yield all items in every iterable returned by the mapper when applied to every item in the source iterable
Yield all items in every iterable returned by the mapper when applied to every item in the source iterable
function flatMap(mapper) {
    return function (iterable) {
        return __asyncGenerator(this, arguments, function* () {
            var e_3, _a, e_4, _b;
            let index = 0;
            try {
                for (var iterable_2 = __asyncValues(iterable), iterable_2_1; iterable_2_1 = yield __await(iterable_2.next()), !iterable_2_1.done;) {
                    const value = iterable_2_1.value;
                    const innerAsyncIterableProm = mapper(value, index);
                    try {
                        for (var innerAsyncIterableProm_1 = __asyncValues(innerAsyncIterableProm), innerAsyncIterableProm_1_1; innerAsyncIterableProm_1_1 = yield __await(innerAsyncIterableProm_1.next()), !innerAsyncIterableProm_1_1.done;) {
                            const inner = innerAsyncIterableProm_1_1.value;
                            yield yield __await(inner);
                        }
                    }
                    catch (e_4_1) { e_4 = { error: e_4_1 }; }
                    finally {
                        try {
                            if (innerAsyncIterableProm_1_1 && !innerAsyncIterableProm_1_1.done && (_b = innerAsyncIterableProm_1.return)) yield __await(_b.call(innerAsyncIterableProm_1));
                        }
                        finally { if (e_4) throw e_4.error; }
                    }
                    index = index + 1;
                }
            }
            catch (e_3_1) { e_3 = { error: e_3_1 }; }
            finally {
                try {
                    if (iterable_2_1 && !iterable_2_1.done && (_a = iterable_2.return)) yield __await(_a.call(iterable_2));
                }
                finally { if (e_3) throw e_3.error; }
            }
        });
    };
}
function flatMap ( mapper ) { return function ( iterable ) { return __asyncGenerator ( this , arguments , function * ( ) { var e_3 , _a , e_4 , _b ; let index = 0 ; try { for ( var iterable_2 = __asyncValues ( iterable ) , iterable_2_1 ; iterable_2_1 = yield __await ( iterable_2 . next ( ) ) , ! iterable_2_1 . done ; ) { const value = iterable_2_1 . value ; const innerAsyncIterableProm = mapper ( value , index ) ; try { for ( var innerAsyncIterableProm_1 = __asyncValues ( innerAsyncIterableProm ) , innerAsyncIterableProm_1_1 ; innerAsyncIterableProm_1_1 = yield __await ( innerAsyncIterableProm_1 . next ( ) ) , ! innerAsyncIterableProm_1_1 . done ; ) { const inner = innerAsyncIterableProm_1_1 . value ; yield yield __await ( inner ) ; } } catch ( e_4_1 ) { e_4 = { error : e_4_1 } ; } finally { try { if ( innerAsyncIterableProm_1_1 && ! innerAsyncIterableProm_1_1 . done && ( _b = innerAsyncIterableProm_1 . return ) ) yield __await ( _b . call ( innerAsyncIterableProm_1 ) ) ; } finally { if ( e_4 ) throw e_4 . error ; } } index = index + 1 ; } } catch ( e_3_1 ) { e_3 = { error : e_3_1 } ; } finally { try { if ( iterable_2_1 && ! iterable_2_1 . done && ( _a = iterable_2 . return ) ) yield __await ( _a . call ( iterable_2 ) ) ; } finally { if ( e_3 ) throw e_3 . error ; } } } ) ; } ; }
Yield all items in every iterable returned by the mapper when applied to every item in the source iterable
Yield all items in every iterable returned by the mapper when applied to every item in the source iterable