npm.io
1.0.2 • Published 3 years ago

@esfx/iter-grouping

Licence
Apache-2.0
Version
1.0.2
Deps
1
Size
31 kB
Vulns
0
Weekly
0
Stars
233

@esfx/iter-grouping

An API for describing grouped iterables.

Overview

Installation

npm i @esfx/iter-grouping

Usage

import { groupBy } from "@esfx/iter-fn";
import { Grouping } from "@esfx/iter-grouping";

const people = [{ familyName: "Smith", givenName: "Alice" }, { familyName: "Smith", givenName: "Bob" }];
for (const group of groupBy(people, person => person.familyName)) {
    group.key; // "Smith"
    group.values; // Iterable of "Alice", "Bob"
    group instanceof Grouping; // true
}

API

You can read more about the API here.