Function countMapBy

  • Counts the values of an array into a map, with the key being based on a key mapper, and the value being the occurrences of the key mapper result in the initial array.

    Since

    12.0.0

    See

    • groupMapBy
    • groupMapReducingBy

    Returns

    Count map.

    Example

    countMapBy([1, 2, 4, 2, 4, 4], val => val)
    // => Map{1: 1, 2: 2, 4: 3}

    Type Parameters

    • TValue

    • UKey

    Parameters

    • array: readonly TValue[]

      Array to count.

    • keyMapper: ArrayIterator<TValue, UKey>

      Function to use for key generation.

    Returns Map<UKey, number>

Generated using TypeDoc