@extra-map/filter.min

Keeps entries which pass a test. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Usage no npm install needed!

<script type="module">
  import extraMapFilterMin from 'https://cdn.skypack.dev/@extra-map/filter.min';
</script>

README

Keeps entries which pass a test. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Alternatives: filter, filter$.
Similar: map, reduce, filter, filterAt, reject, rejectAt.

This is part of package extra-map.

This is browserified, minified version of @extra-map/filter.
It is exported as global variable map_filter.
CDN: unpkg, jsDelivr.


map.filter(x, ft);
// x:  a map
// ft: test function (v, k, x)
const map = require("extra-map");

var x = new Map([["a", 1], ["b", 2], ["c", 3], ["d", 4], ["e", 5]]);
map.filter(x, v => v % 2 === 1);
// Map(3) { "a" => 1, "c" => 3, "e" => 5 }

map.filter(x, v => v % 2 === 0);
// Map(2) { "b" => 2, "d" => 4 }


References