• Creates a Function that groups all elements of an Iterable by using a Mapper function and returns a Map containing the grouped values for each mapped key.

    Example

    const groupByEvenOdd = groupBy(isEven);
    const result = groupByEvenOdd([1,2,1,3]);
    console.log(result); // Map([[1, [1,1,3]], [0, [2]]])

    Returns

    a Map containing the grouped values

    Type Parameters

    • T

      the Iterable value type

    • K

      the Map key type

    Parameters

    • mapper: Mapper<T, K>

      the key Mapper function

    Returns ((iterable: Iterable<T>) => Map<K, T[]>)

Generated using TypeDoc