Skip to content
Map collection as specified in ECMAScript6
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github chore: Add sponsorship information Jun 14, 2019
lib Move private modules into lib folder Apr 29, 2014
primitive Improve prototype resolution Jul 21, 2015
test Fix initialization Oct 17, 2014
.gitignore Initial Nov 9, 2013
.lint Update lint rules Jul 7, 2015
.travis.yml Update Travis CI configuration Mar 17, 2017
CHANGES v0.1.5 Mar 17, 2017
LICENSE Rename LICENCE to LICENSE Jan 13, 2015 docs: Add Tidelift subscription information Jun 14, 2019
implement.js Initial Nov 9, 2013
index.js Initial Nov 9, 2013
is-implemented.js Relax proper implementation detection Nov 10, 2015
is-map.js Ensure to pass Map.prototype as map Oct 15, 2015
is-native-implemented.js Fix isNativeImplemented Jul 9, 2015
package.json chore: Upgrade tad Jun 14, 2019
polyfill.js Fix prototype resolution Jul 17, 2015
valid-map.js Initial Nov 9, 2013


Map collection as specified in ECMAScript6

v0.1 version does not ensure O(1) algorithm complexity (but O(n)). This shortcoming will be addressed in v1.0


It’s safest to use es6-map as a ponyfill – a polyfill which doesn’t touch global objects:

var Map = require('es6-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 = require('es6-map/polyfill');


$ 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


Best is to refer to specification. Still if you want quick look, follow examples:

var Map = require('es6-map');

var x = {}, y = {}, map = new Map([['raz', 'one'], ['dwa', 'two'], [x, y]]);

map.size;                 // 3
map.get('raz');           // 'one'
map.get(x);               // y
map.has('raz');           // true
map.has(x);               // true
map.has('foo');           // false
map.set('trzy', 'three'); // map
map.size                  // 4
map.get('trzy');          // 'three'
map.has('trzy');          // true
map.has('dwa');           // true
map.delete('dwa');        // true
map.size;                 // 3

map.forEach(function (value, key) {
  // { 'raz', 'one' }, { x, y }, { 'trzy', 'three' } iterated

// FF nightly only:
for (value of map) {
 // ['raz', 'one'], [x, y], ['trzy', 'three'] iterated

var iterator = map.values();; // { done: false, value: 'one' }; // { done: false, value: y }; // { done: false, value: 'three' }; // { done: true, value: undefined }

map.clear(); // undefined
map.size; // 0

Tests Build Status

$ npm test

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

Get professional support for d with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
You can’t perform that action at this time.