• Reduces an array to an object using a mapping function.

    Return a tuple of [key, value] in the mapping function to add or replace a property to the resulting object.

    Type Parameters

    • const T

      The type of elements in the array.

    • const TReturn

      The type of the value returned by the mapping function.

    • const TAssignment extends [Readonly<PropertyKey>, TReturn]

      The type of the assignment tuple returned by the mapping function.

    Parameters

    • collection: T[]

      The array to be reduced.

    • fn: ((curr, i, collection) => undefined | TAssignment)

      The mapping function that transforms each element of the array into an assignment tuple.

        • (curr, i, collection): undefined | TAssignment
        • Parameters

          • curr: T
          • i: number
          • collection: T[]

          Returns undefined | TAssignment

    Returns {
        [K in TAssignment[0]]?: TAssignment[1]
    }

    An object where the keys are the first elements of the assignment tuples and the values are the second elements.

Generated using TypeDoc