@extra-iterable/count-on

Counts occurrences of values.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-iterable/count-on
512.3.03 years ago3 years agoMinified + gzip package size for @extra-iterable/count-on in KB

Readme

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

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