Mohammad Asif cf937194cb Removed un-waned things 1. | 5 maanden geleden | |
---|---|---|
.. | ||
src | 5 maanden geleden | |
tests | 5 maanden geleden | |
.npmignore | 5 maanden geleden | |
LICENSE | 5 maanden geleden | |
README.md | 5 maanden geleden | |
jasmine.json | 5 maanden geleden | |
map-or-similar.js | 5 maanden geleden | |
map-or-similar.min.gzip.js | 5 maanden geleden | |
map-or-similar.min.js | 5 maanden geleden | |
package.json | 5 maanden geleden |
Returns a JavaScript Map() or a similar object with the same interface, if Map is not available. Focuses on performance. No dependencies. Made for the browser and nodejs.
npm install map-or-similar --save
var MapOrSimilar = require('map-or-similar');
// make a new map or similar object
var myMap = new MapOrSimilar();
// use it like a map
myMap.set('key1', 'value1');
myMap.set({ val: 'complex object as key' }, 'value2');
The following methods and properties are supported identically to Map():
set(key, val) : Sets a value to a key. Key can be a complex object, array, etc.
get(key) : Returns the value of a key.
has(key) : Returns true if the key exists, otherwise false.
delete(key) : Deletes a key and its value.
forEach(callback) : Invokes callback(val, key, object) once for each key-value pair in insertion order.
size : Returns the number of keys-value pairs.
Does not support other Map methods or properties.
npm run test
Released under an MIT license.