count - nodef/extra-iterable GitHub Wiki

Count values which satisfy a test.

Alternatives: count, countAs. Similar: count, partition.

function count(x, ft)
// x:  an iterable
// ft: test function (v, i, x)
const xiterable = require('extra-iterable');

var x = [1, 1, 2, 2, 4];
xiterable.count(x, v => v % 2 === 1);
// → 2

xiterable.count(x, v => v % 2 === 0);
// → 3

References