ez-map

1.1.1 • Public • Published

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

/ez-map/

    Package Sidebar

    Install

    npm i ez-map

    Weekly Downloads

    0

    Version

    1.1.1

    License

    MIT

    Last publish

    Collaborators

    • gummesson