Noncollinear Perpendicular Microcrystalline
    Wondering what’s next for npm?Check out our public roadmap! »

    @extra-iterable/count-as
    TypeScript icon, indicating that this package has built-in type declarations

    2.5.22 • Public • Published

    Counts occurrences of values. 📦 😺 🏃 📼 🌔 📜 📰 📘

    Alternatives: count, countAs.
    Similar: count, partition.

    This is part of package extra-iterable.


    iterable.countAs(x, [fm]);
    // x:  an iterable
    // fm: map function (v, i, x)
    // → Map {value => count}
    const iterable = require("extra-iterable");
    
    var x = [1, 1, 2, 2, 4];
    iterable.countAs(x);
    // Map(3) { 1 => 2, 2 => 2, 4 => 1 }
    
    var x = [1, 2, 3, 4];
    iterable.countAs(x, v => v % 2);
    // Map(2) { 1 => 2, 0 => 2 }


    References

    Install

    npm i @extra-iterable/count-as

    DownloadsWeekly Downloads

    9

    Version

    2.5.22

    License

    MIT

    Unpacked Size

    4.53 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar