filter-map
![Build Status](https://travis-ci.org/matthewlucock/filter-map.svg?branch=master)
A filter function for JavaScript Maps. Constructs a new Map with every key-value pair from the given map that satisfies a given function.
You can get it with npm i filter-map
.
const filterMap = require("filter-map");
const exampleMap = new Map([
["a", 1],
["b", 2],
["c", 3],
["d", 4]
]);
const filteredMap = filterMap(exampleMap, (key, value) => value % 2);
filteredMap.has("a");
filteredMap.has("b");
filteredMap.has("c");
filteredMap.has("d");
filterMap
takes a Map and a filtering function, and returns the newly constructed Map. The filtering function takes a key and a value, and can return any value, which is then casted to a Boolean to determine whether to filter the key-value pair.