Counts occurrences of values.
Alternatives: one, one-map, all-map.
This is part of package extra-array.
array.countAllOn(x, [fn], [ths]);
// x: an array
// fn: map function (v, i, x)
// ths: this argument
// --> occurrences
const array = require('extra-array');
var x = [1, 1, 2, 2, 4];
array.countOn(x, 2);
// 2 ^ ^
var x = [1, 1, 2, 2, 4];
array.countOn(x, 3, v => v % 2);
// 2 ^ ^