JSPM

  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q62966F
  • License MIT

Counts occurrences of values.

Package Exports

  • @extra-array/count-all-on.min

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@extra-array/count-all-on.min) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Counts occurrences of values.

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

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

array.countAllOn(x, [fn], [ths]);
// x:   an array
// fn:  map function (v, i, x)
// ths: this argument
// --> occurrences
const array = require('extra-array');

var x = [1, 1, 2, 2, 4];
array.countOn(x, 2);
// 2           ^  ^

var x = [1, 1, 2, 2, 4];
array.countOn(x, 3, v => v % 2);
// 2     ^  ^

references