Function groupMapBy

  • Groups the elements of an array into a map, with the key being based on a key mapper, and the value being the values for the same key mapper result.

    Since

    6.1.0

    See

    groupMapReducingBy

    Returns

    Grouped map.

    Example

    groupMapBy([1, 2, 3, 4, 5], val => val % 2)
    // => Map{0: [2, 4], 1: [1, 3, 5]}

    Type Parameters

    • TValue

    • UKey

    Parameters

    • array: readonly TValue[]

      Array to group.

    • keyMapper: ArrayIterator<TValue, UKey>

      Function returning the key for the value.

    Returns Map<UKey, TValue[]>

Generated using TypeDoc