@esfx/iter-grouping Package
An API for describing grouped iterables.
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
}
Classes
Grouping
Represents a group of values associated with the same key.