@szilanor/stream
    Preparing search index...

    Function groupByAsync

    • Returns a collector that creates a group of entries where the group key is calculated by the selector function.

      Type Parameters

      • T

        Type of items in the source.

      • TKey

        Type of the group key.

      Parameters

      • keySelector: (entry: T) => TKey

        A function that returns the group key for each entry.

      Returns AsyncCollectorFunction<T, Map<TKey, T[]>>

      Collector that creates a group of entries where the group key is calculated by the selector function.

      const result = groupByAsync((x) => x % 2)([1, 2, 3]);
      console.log(result); // Map { 1 => [1, 3], 0 => [2] }