Not working for primitives?
Opened this issue · 3 comments
martijnthe commented
The doc says:
The Object can be a regular Object, an Array, a Function, a RegExp, or any of the primitive types or constructor function created with new.
The "or any of the primitive types" part suggests that plain string, number, boolean, etc. should also work, but this doesn't seem to be the case to me. Can you clarify?
cc @jiangzidong
rpaterson commented
I am similarly disappointed. Here's the error:
$ node -e "require('weak')('a string')"
/home/rpaterson/programming/signpost/essentials/node_modules/weak/lib/weak.js:49
var weakref = bindings._create(obj, new Emitter());
^
TypeError: Object expected
at TypeError (native)
at create (/home/rpaterson/programming/signpost/essentials/node_modules/weak/lib/weak.js:49:26)
at [eval]:1:16
at ContextifyScript.Script.runInThisContext (vm.js:25:33)
at Object.exports.runInThisContext (vm.js:77:17)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:570:32)
at Immediate.<anonymous> (bootstrap_node.js:357:29)
at runCallback (timers.js:637:20)
at tryOnImmediate (timers.js:610:5)
rpaterson commented
Javascript has built-in WeakMap
and WeakSet
now, but they only support Objects as well. I was hoping that I could build a weak Map/Set impl for Strings based on this module.