Similar to Array.reduce, but the accumulator can returns Promise.

The array to be reduced.

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

The initial value.

The accumulated result.

  • Similar to Array.reduce, but the accumulator can returns Promise.

    Type Parameters

    • T
    • V

    Parameters

    • values: T[]

      The array to be reduced.

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

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

        • (a, b):
              | undefined
              | null
              | void
              | T
              | Promise<
                  | undefined
                  | null
                  | void
                  | T>
        • Parameters

          Returns
              | undefined
              | null
              | void
              | T
              | Promise<
                  | undefined
                  | null
                  | void
                  | T>

    Returns Promise<T>

    The accumulated result.

  • Similar to Array.reduce, but the accumulator can returns Promise.

    Type Parameters

    • T
    • V

    Parameters

    • values: V[]

      The array to be reduced.

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

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

        • (a, b, i, values):
              | undefined
              | null
              | void
              | T
              | Promise<
                  | undefined
                  | null
                  | void
                  | T>
        • Parameters

          • a: T
          • b: V
          • i: number
          • values: V[]

          Returns
              | undefined
              | null
              | void
              | T
              | Promise<
                  | undefined
                  | null
                  | void
                  | T>

    • init: T | Promise<T>

      The initial value.

    Returns Promise<T>

    The accumulated result.