-
Notifications
You must be signed in to change notification settings - Fork 1
countAs
Subhajit Sahu edited this page Jun 15, 2020
·
17 revisions
Counts occurrences of values. 🏃 📼 📦 🌔 📒
iterable.countAs(x, [fn]);
// x: an iterable
// fn: 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 }