CCC Docs
    Preparing search index...

    Function reduceAsync

    Similar to Array.reduce, but works on async iterables and the accumulator can return a Promise.

    The iterable or async iterable to be reduced.

    A callback to be called for each value. If it returns null or undefined, the previous result will be kept.

    The initial value.

    The accumulated result.

    • Similar to Array.reduce, but works on async iterables and the accumulator can return a Promise.

      Type Parameters

      • T

      Parameters

      • values: Iterable<T, any, any> | AsyncIterable<T, any, any>

        The iterable or async iterable to be reduced.

      • accumulator: (
            a: T,
            b: T,
            i: number,
        ) => undefined | null | void | T | Promise<undefined | null | void | T>

        A callback to be called for each value. If it returns null or undefined, the previous result will be kept.

      Returns Promise<T>

      The accumulated result.

    • Similar to Array.reduce, but works on async iterables and the accumulator can return a Promise.

      Type Parameters

      • T
      • V

      Parameters

      • values: Iterable<V, any, any> | AsyncIterable<V, any, any>

        The iterable or async iterable to be reduced.

      • accumulator: (
            a: T,
            b: V,
            i: number,
        ) => undefined | null | void | T | Promise<undefined | null | void | T>

        A callback to be called for each value. If it returns null or undefined, the previous result will be kept.

      • init: T | Promise<T>

        The initial value.

      Returns Promise<T>

      The accumulated result.