Skip to content

gummesson/ez-map

Repository files navigation

ez-map

NPM version License Build status

A basic Map-like implementation.

Installation

npm install ez-map

Usage

var EzMap = require('ez-map')
var map   = new EzMap([
  ['foo', 'bar']
])

map.set('baz')
map.has('foo') // => true
map.get('baz') // => undefined

map.keys()    // => ['foo', 'baz']
map.values()  // => ['bar', undefined]
map.entries() // => [['foo', 'bar'], ['baz', undefined]]
map.size()    // => 2

map.forEach(function(value, key, context) {
  console.log(value)   // => <value>
  console.log(key)     // => <key>
  console.log(context) // => <map>
})

map.delete('foo') // => true
map.delete('qux') // => false
map.clear()

Differences

  • .entries() is the only way to get the entries.
  • .size() (instead of .size) to get the size of the entries.
  • .forEach() has no parameter for passing the context.

See also

About

A basic Map-like implementation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published