0.1.5 • Published 7 years ago

es6-map v0.1.5

Weekly downloads
1,915,949
License
MIT
Repository
github
Last release
7 years ago

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

If you want to make sure your environment implements Map globally, do:

require('es6-map/implement');

If you strictly want to use the polyfill even if the native Map exists, do:

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

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 = 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();

iterator.next(); // { done: false, value: 'one' }
iterator.next(); // { done: false, value: y }
iterator.next(); // { done: false, value: 'three' }
iterator.next(); // { done: true, value: undefined }

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

Tests Build Status

$ npm test
sms-fluidcomponents-sass-importer@sitegeist/sms-sass-importersms-sass-importerve-playersass-modules-importercthpb-plugin-social@infinitebrahmanuniverse/nolb-es6@everything-registry/sub-chunk-1596echat-js-sdkeasyplayer-myelc-cyardestapeslint-import-coreeslint-plugin-aurelia-event-aggregatorenact-dev@pnp/polyfill-ie11observable-mapobservable-multi-setdomjsoutils-ren@kmwork/front-core@ngxvoice/ngx-voicelistnerdbjsdbjs-extdbjs-persistencenomad-slate@openrc/react-native-mqttcaleres-sass-module-importercarousel-reacttest-node-red-contrib-opcuavenom-player@kronoverse/ioredis-mock@krwhitley/neatapticnode-red-contrib-opcua-mpsnode-red-contrib-opcua-temponode-red-contrib-opcua-zhvcloudcam-playkit-js-hlsnode-red-contrib-simatic-opcua-eventcrunch-js@kristoffertonning/vue-laravel-errors@lets-talk/embedded-lispnode-red-contrib-novakonpictawall.sdk@spalger/eslint-plugin-importwonder-slatewow.js-juzixdatplaykit-js-hls-sondq@pathable/slateobject-cache-graph-thing@rxjs/rxdolphin-mq@numso/eslint-plugin-importpolity@the91end/react-auth@thedoctor0/vuex-shared-mutations@socialtables/openfpcwy-webvideo-sdk@reagentum/front-corecourse-vue-tpl@opuscapita/slate@orangesk/orange-design-systemvue-v3-yandex-metrika@rstacruz/pnpmmercury-sdk-jstick-map@inovando-boletos/boletothing-it-device-amxthing-it-device-bacnetcluster-contractormqtt-no-shebangmqttjx@innodata/vue-v3-ya-metrikatovar.jszy_sdk@quarterto/eq@qintx/zeditor@taoqf/react-native-mqttharo-redisharo-couchbaseharo-memcachedgraphsgrunt-vca-element-releaseeslint-bundledes-env-polyfillsesees6-translatef--levent-processorevergreen22-org-crawlerfluid-eslinthelp-widgethttp-deduplicatehrflowfahad-redux-axios-midlewarefailpointsfirst-app-lyfucifirmata-electrongl-enginefreemamba
0.1.5

7 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

9 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago