es6-map
Map collection as specified in ECMAScript6
Warning:
v0.1 version does not ensure O(1) algorithm complexity (but O(n)). This shortcoming will be addressed in v1.0
Usage
It’s safest to use es6-map as a ponyfill – a polyfill which doesn’t touch global objects:
var Map = ;
If you want to make sure your environment implements Map
globally, do:
;
If you strictly want to use the polyfill even if the native Map
exists, do:
var Map = ;
Installation
$ npm install es6-map
To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: Browserify, Webmake or Webpack
API
Best is to refer to specification. Still if you want quick look, follow examples:
var Map = ; var x = {} y = {} map = 'raz' 'one' 'dwa' 'two' x y; mapsize; // 3map; // 'one'map; // ymap; // truemap; // truemap; // falsemap; // mapmapsize // 4map; // 'three'map; // truemap; // truemap; // truemapsize; // 3 map; // FF nightly only:for value of map // ['raz', 'one'], [x, y], ['trzy', 'three'] iterated var iterator = map; iteratornext; // { done: false, value: 'one' }iteratornext; // { done: false, value: y }iteratornext; // { done: false, value: 'three' }iteratornext; // { done: true, value: undefined } mapclear; // undefinedmapsize; // 0
$ npm test