array-to-map
Light utility to convert your [keys] to a {key:key} map
Last updated 10 years ago by ashubham .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install array-to-map 
SYNC missed versions from official npm registry.

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'}

Current Tags

  • 1.0.3                                ...           latest (10 years ago)

4 Versions

  • 1.0.3                                ...           10 years ago
  • 1.0.2                                ...           11 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |