• Example

    const [first, second, third, fourth] = groupByIndex(
    [1, 2, 100, 200],
    (num) => num.toString().length - 1
    );
    // first → [1, 2]
    // second → []
    // third → [100, 200]
    // fourth → undefined

    Type Parameters

    Type Parameters

    • T

    Parameters

    • values: Iterable<T>
    • indexSelector: ((item: T) => number)
        • (item: T): number
        • Parameters

          • item: T

          Returns number

    Returns T[][]

Generated using TypeDoc