@extra-iterable/count-on.min

Counts occurrences of values. [:running:] [:vhs:] [:package:] [:moon:] [:ledger:] > Alternatives: [one], [all]. > This is part of package [extra-iterable].

Usage no npm install needed!

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

README

Counts occurrences of values. :running: :vhs: :package: :moon: :ledger:

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

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

iterable.countOn(x, [fn], [ths]);
// x:   an iterable
// fn:  map function (v, i, x)
// ths: this argument
// --> Map {value => count}
const iterable = require('extra-iterable');

var x = [1, 1, 2, 2, 4];
iterable.countOn(x);
// Map(3) { 1 => 2, 2 => 2, 4 => 1 }

var x = [1, 2, 3, 4];
iterable.countOn(x, v => v % 2);
// Map(2) { 1 => 2, 0 => 2 }

references