1.0.0 • Published 9 years ago

to-map v1.0.0

Weekly downloads
2
License
WTFPL
Repository
github
Last release
9 years ago

to-map

Converts a regular object into a map

npm install -S to-map

Example

import toMap from 'to-map'

let map = toMap({
  foo: 'foo'
})

map.get( 'foo' ) // 'foo'

Restrictions

Map is not supported everywhere, however, babel will happily allow Maps to work in modern browsers.

The key advantages of using a Map over a plain ole JS object are probably:

  • .size property is pretty handy
  • Various utility methods exist on maps but not objects
  • Iterators!

There are probably loads more, and a few negatives maybe too. Performance is often hit at, but unless your application has a metric ton of data to convert frequently then any performance issues aren’t going to be caused by using maps.

Immutability

I love immutable maps of data too but plenty of implementations already exist.

Install

Use npm

npm i -S to-map

License

WTFPL

1.0.0

9 years ago

0.1.0

9 years ago