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

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

    2.2.5 • Public • Published

    Counts occurrences of values. 🏃 📼 📦 🌔 📒

    Alternatives: count, countAs.
    This is part of package extra-object.

    object.countAs(x, fm);
    // x:  an object
    // fm: map function (v, k, x)
    // --> Map {value => count}
    const object = require('extra-object');
    
    var x = {a: 1, b: 1, c: 2, d: 2, e: 4};
    object.countAs(x);
    // Map(3) { 1 => 2, 2 => 2, 4 => 1 }
    
    var x = {a: 1, b: 2, c: 3, d: 4};
    object.countAs(x, v => v % 2);
    // Map(2) { 1 => 2, 0 => 2 }

    references

    Install

    npm i @extra-object/count-as

    DownloadsWeekly Downloads

    52

    Version

    2.2.5

    License

    MIT

    Unpacked Size

    7.52 kB

    Total Files

    19

    Last publish

    Collaborators

    • avatar