-
Notifications
You must be signed in to change notification settings - Fork 0
countAs
Subhajit Sahu edited this page Dec 22, 2022
·
14 revisions
Count occurrences of values.
function countAs(x, fm)
// x: entries
// fm: map function (v, k, x)
const entries = require('extra-entries');
var x = [["a", 1], ["b", 1], ["c", 2], ["d", 2], ["e", 4]];
entries.countAs(x);
// → Map(3) { 1 => 2, 2 => 2, 4 => 1 }
var x = [["a", 1], ["b", 2], ["c", 3], ["d", 4]];
entries.countAs(x, v => v % 2);
// → Map(2) { 1 => 2, 0 => 2 }