• Reduces an array of elements into a multi-object based on a provided mapping function. The mapping function should return an array of key-value pairs, where the key represents the property name in the resulting multi-object, and the value represents the corresponding value to be added to the array of values for that property.

    Type Parameters

    • const T

      The type of elements in the collection.

    • const TReturn

      The type of the values in the resulting multi-object.

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

      The type of the key-value pairs returned by the mapping function.

    Parameters

    • collection: T[]

      The array of elements to be reduced.

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

      The mapping function.

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

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

          Returns undefined | TAssignment

    Returns {
        [K in Readonly<PropertyKey>]?: TAssignment[1][]
    }

    The resulting multi-object.

Generated using TypeDoc