@extra-array/count-as
v2.10.19
Published
Counts occurrences of values.
Downloads
127
Readme
Counts occurrences of values. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:
This is part of package extra-array.
array.countAs(x, [fm]);
// x: an array
// fm: map function (v, i, x)
// → Map {value => count}
const array = require("extra-array");
var x = [1, 1, 2, 2, 4];
array.countAs(x);
// Map(3) { 1 => 2, 2 => 2, 4 => 1 }
var x = [1, 2, 3, 4];
array.countAs(x, v => v % 2);
// Map(2) { 1 => 2, 0 => 2 }