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

map-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

map-map

Applies a callback to each key-value pair of a Map or Object.

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-41.67%
Maintainers
1
Weekly downloads
 
Created
Source

map-map

Applies a callback to each key-value pair of a Map, Object, or other collection. The original collection is not modified; a copy is returned.

Installation

Requires Node.js 7.0.0 or above.

npm i map-map

API

The module exports a single function.

Parameters

  1. Bindable: map (Array, iterator, Object, Map, Set, string, or Typed Array)
  2. mapper (function): The callback which receives three arguments (key, value, and index) and which returns a two-element array containing the new key and value.
  3. Optional: options: Object argument which is forwarded to entries-array, a dependency of this module.

Return Value

A copy of map which has had mapper applied to each of its key-value pairs.

Example

const mapMap = require('map-map')

let map = new Map([['key', 'value']])
map = mapMap(map, (key, value, index) => [key + '_mapped', value + '_mapped'])
map.get('key_mapped') // 'value_mapped'

Works on Objects too:

const mapMap = require('map-map')

let obj = {key: 'value'}
obj = mapMap(obj, (key, value, index) => [key + '_mapped', value + '_mapped'])
obj.key_mapped // 'value_mapped'

Keywords

FAQs

Package last updated on 03 Nov 2018

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