Nested Parenthetical Madness
    Have ideas to improve npm?Join in the discussion! »

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

    2.10.18 • Public • Published

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

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

    This is part of package extra-array.


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


    References

    Install

    npm i @extra-array/count-as

    DownloadsWeekly Downloads

    121

    Version

    2.10.18

    License

    MIT

    Unpacked Size

    4.34 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar