dist/async-iterable/operators.js
/** Reduce the items in an iterable down to a single instance of the same type as the type contained by that AsyncIterable */
Reduce the items in an iterable down to a single instance of the same type as the type contained by that AsyncIterable
Reduce the items in an iterable down to a single instance of the same type as the type contained by that AsyncIterable
function fold(predicate) {
    return async function (iterable) {
        var e_8, _a;
        let index = 0;
        let prevState;
        try {
            for (var iterable_6 = __asyncValues(iterable), iterable_6_1; iterable_6_1 = await iterable_6.next(), !iterable_6_1.done;) {
                const value = iterable_6_1.value;
                if (index == 0) {
                    prevState = value;
                }
                else {
                    prevState = await predicate(prevState, value, index);
                }
                index = index + 1;
            }
        }
        catch (e_8_1) { e_8 = { error: e_8_1 }; }
        finally {
            try {
                if (iterable_6_1 && !iterable_6_1.done && (_a = iterable_6.return)) await _a.call(iterable_6);
            }
            finally { if (e_8) throw e_8.error; }
        }
        return prevState;
    };
}
function fold ( predicate ) { return async function ( iterable ) { var e_8 , _a ; let index = 0 ; let prevState ; try { for ( var iterable_6 = __asyncValues ( iterable ) , iterable_6_1 ; iterable_6_1 = await iterable_6 . next ( ) , ! iterable_6_1 . done ; ) { const value = iterable_6_1 . value ; if ( index == 0 ) { prevState = value ; } else { prevState = await predicate ( prevState , value , index ) ; } index = index + 1 ; } } catch ( e_8_1 ) { e_8 = { error : e_8_1 } ; } finally { try { if ( iterable_6_1 && ! iterable_6_1 . done && ( _a = iterable_6 . return ) ) await _a . call ( iterable_6 ) ; } finally { if ( e_8 ) throw e_8 . error ; } } return prevState ; } ; }
Reduce the items in an iterable down to a single instance of the same type as the type contained by that AsyncIterable
Reduce the items in an iterable down to a single instance of the same type as the type contained by that AsyncIterable