-
Notifications
You must be signed in to change notification settings - Fork 0
count
Subhajit Sahu edited this page Jun 17, 2020
·
14 revisions
Counts values which satisfy a test. 🏃 📼 📦 🌔 📒
Alternatives: [count], [countAs].
entries.count(x, fn);
// x: a map
// fn: test function (v, k, x)
const entries = require('extra-entries');
var x = new Map([['a', 1], ['b', 1], ['c', 2], ['d', 2], ['e', 4]]);
map.count(x, v => v % 2 === 1);
// 2
map.count(x, v => v % 2 === 0);
// 3