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.
sigonasr2
0785506fad
|
5 years ago | |
---|---|---|
.. | ||
.eslintrc.json | 5 years ago | |
.travis.yml | 5 years ago | |
index.js | 5 years ago | |
package.json | 5 years ago | |
readme.md | 5 years ago | |
test.js | 5 years ago |
readme.md
primitive-pool
Get object for a primitive value. Useful to make WeakMap store strings/numbers and other primitives.
Usage
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'