2.0.3 • Published 5 years ago

es6-weak-map v2.0.3

Weekly downloads
4,378,122
License
ISC
Repository
github
Last release
5 years ago

Build status Windows status Transpilation status npm version

es6-weak-map

WeakMap collection as specified in ECMAScript6

Roughly inspired by Mark Miller's and Kris Kowal's WeakMap implementation.

Differences are:

  • Assumes compliant ES5 environment (no weird ES3 workarounds or hacks)
  • Well modularized CJS style
  • Based on one solution.

Limitations

  • Will fail on non extensible objects provided as keys

Installation

$ npm install es6-weak-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

Usage

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

require("es6-weak-map/implement");

If you'd like to use native version when it exists and fallback to polyfill if it doesn't, but without implementing WeakMap on global scope, do:

var WeakMap = require("es6-weak-map");

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

var WeakMap = require("es6-weak-map/polyfill");

API

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

var WeakMap = require("es6-weak-map");

var map = new WeakMap();
var obj = {};

map.set(obj, "foo"); // map
map.get(obj); // 'foo'
map.has(obj); // true
map.delete(obj); // true
map.get(obj); // undefined
map.has(obj); // false
map.set(obj, "bar"); // map
map.has(obj); // false

Tests

$ npm test
memoizeecthpb-plugin-socialunblock-block-save-variables@infinitebrahmanuniverse/nolb-es6@everything-registry/sub-chunk-1597help-widget@etpinard/gl-textgulp-fun-stylejeuxuijs-utils-jll2idempotent-bindneural_compressor_ext_lab_customizedneural_compressor_ext_lab_customized_2m2m-chartjs-plugin-crosshairmakaramemoizee-2mapbox-materialise-style-languagelrbceshin8n-nodes-caldav3.0.0@brucearmstrong/sass-librarylayui-customemissaryeasyplayer-myeslint-plugin-aurelia-event-aggregatorestree-parentes-env-polyfillsfront-remap-istanbulglamor-jssgit-repo-initgl-texthcm-jsfirst-app-lyfucifast-keyfahad-redux-axios-midlewarefenglin-uploaderextension-coordinator1freemambagasmnode-stubby-server-cliobservable-setpyplan-bokehjsrangoli-csspixiu-swap-coreoutils-renoprahphpcorephptestplaykit-js-hls-sondqrcfproperty-accessorspictawall.sdkpingan-paymentpinganpayrestakebotsearch-input-reactsearch-list-react@headgum/tko-mapping@faizanhaider/iconsax@igniswap/igni-swap-lib@ivanljutyj/embed.js@futureverse/nx-semantic-release-sync@isogand/react-native-sliding-countervideo-multi-uploadertraceviewvue-v3-yandex-metrika@mblode/react-native-feather@kmwork/front-core@min98/layui-custom@krwhitley/neataptic@kristoffertonning/vue-laravel-errors@innodata/vue-v3-ya-metrika@inovando-boletos/boletoweb-elements-iconsyomothyvcloudcam-playkit-js-hls@lofcz/sweetalert2-neutral@litedexdev/litedex-core-swap@ngxvoice/ngx-voicelistnerwow.js-juziswipe-upsp-build-taskssolregex2spellbindsaitoreactive-setsimply-uiredux-localregression-external-dtoregl-line2drenrendai@reagentum/front-core@theunderscorer/nx-semantic-release@the91end/react-auth@thismr/bitmindtest-core@triply/ratt@uniter/phpcore@quarterto/cache-if@rstacruz/pnpm
2.0.3

5 years ago

2.0.2

7 years ago

2.0.1

8 years ago

2.0.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.0

10 years ago