Not really an answer to your question, but more of a warning regarding overriding inheritance:
Assigning the __proto__
property of an object or using the ES6 equivalent Object.setPrototypeOf()
has severe performance impacts on any code path that is touched by such an object.
Blog post with benchmarks showing some of the performance impact.
Firefox emits a warning when you do this:
mutating the [[Prototype]] of an object will cause your code to run very slowly;
instead create the object with the correct initial [[Prototype]] value using Object.create
To quote from mozilla bug 984146
The __proto__ is deadly for the type inference, basically, after doing that
this means that Type Inference is unable to follow any of the properties of
the object as you are changing the underlying object lookup behind his back.
This basically means that every lookup you do on this object or any object
created with this constructor will fallback on a slow path for
reading/writing properties to the object. I might under estimate this
issue, Eric would know better. (ni: efaust)
It's even worse than that.
When you set __proto__, not only are you ruining any chances you may
have had for future optimizations from Ion on that object, but you
also force the engine to go crawling around to all the other pieces of
TI (information about function return values, or property values,
perhaps) which think they know about this object and tell them not to
make many assumptions either, which involves further deoptimization
and perhaps invalidation of existing jitcode.
Changing the prototype of an object in the middle of execution is
really a nasty sledgehammer, and the only way we have to keep from
being wrong is to play it safe, but safe is slow. If possible, try to
create directly with prototype chain you want. If we really have to
swizzle prototype chains around dynamically, I'm not sure I have great
advice as to how to minimize the performance implications of that
action.