array-to-map

1.0.3 • Public • Published

array-to-map

Light utility to convert your [keys] to a {key:key} map

Usage

var getMap = require('array-to-map');
 
var map = getMap([1, 2, "abc"]);
// {'1':1, '2':2, 'abc':'abc'}

The best use case for this tool is when a conversion from an array to a map is needed for efficient membership checking.

Gotchas

Unserializable elements like objects and functions are ignored by this tool.

So something like,

var getMap = require('array-to-map');
 
var map = getMap([1, 2, "abc", {key:123}, function () {}]);
// Still {'1':1, '2':2, 'abc':'abc'}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    1
  • 1.0.2
    0
  • 1.0.1
    1
  • 1.0.0
    0

Package Sidebar

Install

npm i array-to-map

Weekly Downloads

2

Version

1.0.3

License

MIT

Last publish

Collaborators

  • ashubham