In light of this thread and the recent discussion about some kind of .?
 operator, I thought it'd be cool to actually make this and try it out. By
having a bit of fine with the V8 API's* _MarkAsUndetectable_ *function and
building on top of that, I was able to make a node module as an experiment
in seeing it in action. Sadly I couldn't reproduce the behavior in
Spidermonkey (the API is unimplemented in v8monkey and I couldn't find a
way to do it).

I created an object (called nil) that is marked as undetectable (typeof is
'undefined', in null equality class, falsey) that returns itself for all
property access (except for toStrnig), returns itself when called as a
function, has null as a prototype, and returns the empty string when
coerced to string.

I also implemented a rough proxy wrapper that allows you to wrap an object
such that in all places it normally would return undefined instead returns
nil. I also created a recursive membrane version that wraps all
non-primitive return values with the same kind of handler.

https://github.com/Benvie/nil
https://npmjs.org/package/nil
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to