@extra-iterable/count-as

Counts occurrences of values.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-iterable/count-as
102.5.222 years ago2 years agoMinified + gzip package size for @extra-iterable/count-as in KB

Readme

Counts occurrences of values. :package: :smileycat: :running: :vhs: :moon: :scroll: :newspaper: :bluebook:
Alternatives: count, countAs.
Similar: count, partition.

This is part of package extra-iterable.



iterable.countAs(x, [fm]);
// x:  an iterable
// fm: map function (v, i, x)
// → Map {value => count}

const iterable = require("extra-iterable");

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

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



References