weak-dictionary
Version:
Universal ES6-compatible WeakMap wrapper
49 lines (37 loc) • 1.93 kB
Markdown
#Weak-Dictionary
A memory-safe dictionary implementation using the CoreJS WeakMap polyfill
- [Why](#why)
- [Usage](#usage)
# Why?
ES6 does not contain a weak dictionary API that tracks key's:
- [WeakMap](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
- [WeakSet](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
- [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
- [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
Naturally, we will need a Dictionary implementation that allows managed `key` tracking _without_ preventing `GC` in various JS runtimes.
# Usage
Install:
``` javascript
npm install weak-dictionary
```
Use:
``` javascript
var weakDict = require('weak-dictionary');
var dict = new weakDict();
```
Profit!
----
[![Build Status][travis-shield]][travis]
[![Build Status][travis-shield-develop]][travis]
[![Dependency Status][dependencies-shield]][dependencies]
[![devDependency Status][dependencies-dev-shield]][dependencies-dev]
[![yo][shield]][shield]
[npm]: https://www.npmjs.com/package/weak-dictionary
[travis]: https://travis-ci.org/deepelement/weak-dictionary
[travis-shield]: https://img.shields.io/travis/DeepElement/weak-dictionary.svg?branch=stable
[travis-shield-develop]: https://img.shields.io/travis/DeepElement/weak-dictionary.svg?branch=master
[dependencies]: https://david-dm.org/deepelement/weak-dictionary
[dependencies-dev]: https://david-dm.org/deepelement/weak-dictionary#info=devDependencies
[dependencies-shield]: https://img.shields.io/david/deepelement/weak-dictionary.svg
[dependencies-dev-shield]: https://img.shields.io/david/dev/deepelement/weak-dictionary.svg
[shield]: https://img.shields.io/npm/dm/winjsrocks.svg