This is your problem:
var denullifier; function revocable(unary) { if (denullifier === null) denullifier = unary;
denullifier
is undefined
when declared without a value. However, you are checking for type-strict equality with null
, which will be false
, so denullifier
is never set and porcupine
is not able to restore the unary
function.
I'd suggest:
- Use
==
instead of===
to get equality withundefined
- Even better, use
typeof denullifier != "function"
- Or, (although I don't know your design) you should not make
denullifier
a global, static variable that will be shared amongstrevocable
instances, but instead make it instance-specific by putting the declaration inside the function body.