• Groups all values in the iterable under the computed key, based on the keySelector.

    Example

    const map = groupBy([0, 1, 2, 10, 20, 100, 200], (num) =>
    num.toString().charAt(0)
    );
    // map → [
    // ['0', [0]],
    // ['1', [1, 10, 100]],
    // ['2', [2, 20, 200]],
    // ]

    Type Parameters

    Type Parameters

    • K

    • V

    Parameters

    • values: Iterable<V>
    • keySelector: ((item: V) => K)
        • (item: V): K
        • Parameters

          • item: V

          Returns K

    • destination: Map<K, V[]> = ...

    Returns Map<K, V[]>

Generated using TypeDoc