starry.group-by

4.0.0 • Public • Published

Member of the starry suite—modular functions for iterable objects.

npm node

Status

Applies to the whole suite.

Build Status Coverage Status

Usage

function groupBy<TItem = any, TKey = any, TValue = any>(
  iterable: Iterable<TItem>,
  keySelector: (item: TItem) => TKey = x => x as TItem & TKey,
  valueSelector: (item: TItem) => Tvalue = x => x as TItem & TValue
): Map<TKey, TValue[]>

Groups the elements of an iterable into a map.

Parameters:

  • iterable - Iterable<TItem>
  • keySelector - (item: TItem) => TKey: A function to extract the key for each element. Default: x => x
  • valueSelector - (item: TItem) => TValue: A function to map each element into the output grouping. Default: x => x

Returns: Map<TKey, TValue>

/starry.group-by/

    Package Sidebar

    Install

    npm i starry.group-by

    Weekly Downloads

    1

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    6.38 kB

    Total Files

    9

    Last publish

    Collaborators

    • seangenabe