Skip to content
Subhajit Sahu edited this page Jun 13, 2020 · 17 revisions

Counts values which satisfy a test. 🏃 📼 📦 🌔 📒

Alternatives: count, countAs.

set.count(x, fn, [ths]);
// x:   a set
// fn:  test function (v, v, x)
// ths: this argument
const map = require('extra-map');

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

references

Clone this wiki locally