ez-map
v1.1.1
Published
A basic Map-like implementation.
Downloads
6
Readme
ez-map
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.