Skip to content
Subhajit Sahu edited this page Feb 3, 2021 · 17 revisions

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

Alternatives: count, countAs.

set.count(x, ft);
// x:  a set
// ft: test function (v, v, x)
const set = require('extra-set');

var x = new Set([1, 2, 3, 4, 5]);
set.count(x, v => v % 2 === 1);
// 3

set.count(x, v => v % 2 === 0);
// 2

references

Clone this wiki locally