You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
765 B
26 lines
765 B
# primitive-pool [](http://github.com/badges/stability-badges) [](https://travis-ci.org/dy/primitive-pool)
|
|
|
|
Get object for a primitive value. Useful to make WeakMap store strings/numbers and other primitives.
|
|
|
|
## Usage
|
|
|
|
[](https://npmjs.org/package/primitive-pool/)
|
|
|
|
|
|
```js
|
|
let p = require('primitive-pool')
|
|
|
|
let map = new WeakMap()
|
|
|
|
map.set(p('abc'), 123)
|
|
map.get(p('abc')) // 123
|
|
|
|
map.set(p``, 456)
|
|
map.get(p``) // 456
|
|
|
|
map.set(p(null), 789)
|
|
map.get(p(null)) // 789
|
|
|
|
map.set(p(123), 'abc')
|
|
map.get(p(123)) // 'abc'
|
|
```
|
|
|