Counts occurrences of values.
This is part of package extra-map.
This is browserified, minified version of @extra-map/count-as.
It is exported as global variable map_countAs.
CDN: unpkg, jsDelivr.
map.countAs(x, fm);
// x: a map
// fm: map function (v, k, x)
// → Map {value => count}
const map = require("extra-map");
var x = new Map([["a", 1], ["b", 1], ["c", 2], ["d", 2], ["e", 4]]);
map.countAs(x);
// Map(3) { 1 => 2, 2 => 2, 4 => 1 }
var x = new Map([["a", 1], ["b", 2], ["c", 3], ["d", 4]]);
map.countAs(x, v => v % 2);
// Map(2) { 1 => 2, 0 => 2 }