@extra-array/count-all-on.min

Counts occurrences of values. > Alternatives: [one], [one-map], [all-map]. > This is part of package [extra-array].

Usage no npm install needed!

<script type="module">
  import extraArrayCountAllOnMin from 'https://cdn.skypack.dev/@extra-array/count-all-on.min';
</script>

README

Counts occurrences of values.

Alternatives: one, one-map, all-map.
This is part of package extra-array.

This is browserified, minified version of @extra-array/count-all-on.
It is exported as global variable array_count_all_on.
CDN: unpkg, jsDelivr.

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     ^  ^

references