Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@enkidevs/array-to-map

Package Overview
Dependencies
Maintainers
13
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@enkidevs/array-to-map

Utility for generalized mapping of an array to a map

  • 1.0.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
13
Created
Source

array-to-map

CircleCI npm version

Converting an array into a Map.

const map = arrayToMap([
  { id: 'a', value: 1 },
  { id: 'b', value: 2 },
  { id: 'c', value: 3 },
]);
console.log(map);
/*
{
  {0 => { id: 'a', value: 1 }}
  {1 => { id: 'b', value: 2 }}
  {2 => { id: 'c', value: 3 }}
}
*/

You can decide how the keys are created:

const map = arrayToMap([
  { id: 'a', value: 1 },
  { id: 'b', value: 2 },
  { id: 'c', value: 3 },
], item => item.id);
console.log(map);
/*
{
  {'a' => { id: 'a', value: 1 }}
  {'b' => { id: 'b', value: 2 }}
  {'c' => { id: 'c', value: 3 }}
}
*/

License

MIT

Keywords

FAQs

Package last updated on 05 Apr 2021

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