npm install weakmap-shimA minimal weakmap shim
``js
var weakMap = require("weakmap-shim")
var map = weakMap()
var key = {}
map.set(key, 'some value')
var v = map.get(key) // 'some value'
`
`js
var createStore = require('weakmap-shim/create-store')
var store = createStore()
var key = {}
var value = store(key)
// value is weakly bound to key. value is a plain object
value.foo = 'bar'
var value2 = store(key)
var v = value2.foo; // 'bar'
var bool = value === value2; // true
`
Benvie has an excellent weakmap
module that's far more robust. However it contains quite a bit
of loc.
- weakmap : 7451 bytesweakmap-shim
- : 2106 bytesweakmap-shim/create-store
- : 1311 bytes
This module is only worthwhile if you want to add a weakmap to
a small module (10 - 30 loc) and dont want to bloat it with
a heavier weakmap
npm install weakmap-shim`
- Raynos
[1]: https://secure.travis-ci.org/Raynos/weakmap-shim.png
[2]: https://travis-ci.org/Raynos/weakmap-shim
[3]: https://badge.fury.io/js/weakmap-shim.png
[4]: https://badge.fury.io/js/weakmap-shim
[5]: https://coveralls.io/repos/Raynos/weakmap-shim/badge.png
[6]: https://coveralls.io/r/Raynos/weakmap-shim
[7]: https://gemnasium.com/Raynos/weakmap-shim.png
[8]: https://gemnasium.com/Raynos/weakmap-shim
[9]: https://david-dm.org/Raynos/weakmap-shim.png
[10]: https://david-dm.org/Raynos/weakmap-shim
[11]: https://ci.testling.com/Raynos/weakmap-shim.png
[12]: https://ci.testling.com/Raynos/weakmap-shim