New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

filter-map

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filter-map

A filter function for Maps.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

filter-map

npm npm Build Status

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]
]);

// Filter even-numbered values out of the Map.
const filteredMap = filterMap(exampleMap, (key, value) => value % 2);

filteredMap.has("a"); // true
filteredMap.has("b"); // false
filteredMap.has("c"); // true
filteredMap.has("d"); // false

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.

Keywords

FAQs

Package last updated on 24 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc