plainfp - v0.1.0
    Preparing search index...

    Function groupBy

    • Bucket elements into a record keyed by keyFn. Elements sharing a key are appended to the same bucket in input order.

      Dual API — works data-first or curried for use in pipe.

      Type Parameters

      • T
      • K extends PropertyKey

      Parameters

      • xs: readonly T[]
      • keyFn: (x: T) => K

      Returns Record<K, T[]>

      pipe(
      orders,
      Arrays.groupBy((o) => o.status),
      )
      // { pending: [...], shipped: [...] }
    • Bucket elements into a record keyed by keyFn. Elements sharing a key are appended to the same bucket in input order.

      Dual API — works data-first or curried for use in pipe.

      Type Parameters

      • T
      • K extends PropertyKey

      Parameters

      • keyFn: (x: T) => K

      Returns (xs: readonly T[]) => Record<K, T[]>

      pipe(
      orders,
      Arrays.groupBy((o) => o.status),
      )
      // { pending: [...], shipped: [...] }