@esfx/iter-grouping Package

    An API for describing grouped iterables.

    Installation

    npm i @esfx/iter-grouping
    

    Usage

    • TypeScript
    • JavaScript (CommonJS)
    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
    }
    
    const { groupBy } = require("@esfx/iter-fn");
    const { Grouping } = require("@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.

    HierarchyGrouping

    • Improve this Doc
    Generated by DocFX