You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Digging through the prototype chain of the result of node's vm.createContext reveals that objects returned by it are instances of Context, which seems to be a simple constructor function with a prototype that is a plain old object.
So to emulate node's behaviour, the following needs to be added:
functionContext(){}Context.prototype={};
createContext should return a new Context rather than a new object. It should still perform a shallow copy.
runInContext should throw a TypeError if context is not an instance of Context (having the right prototype is not sufficient). The code that is currently in runInNewContext should be moved here.
runInNewContext should call runInContext with the context argument passed through createContext.
I can create a PR for this behaviour if you want.
The text was updated successfully, but these errors were encountered:
Digging through the prototype chain of the result of node's
vm.createContext
reveals that objects returned by it are instances ofContext
, which seems to be a simple constructor function with a prototype that is a plain old object.So to emulate node's behaviour, the following needs to be added:
createContext
should return anew Context
rather than a new object. It should still perform a shallow copy.runInContext
should throw a TypeError ifcontext
is not an instance ofContext
(having the right prototype is not sufficient). The code that is currently inrunInNewContext
should be moved here.runInNewContext
should callrunInContext
with thecontext
argument passed throughcreateContext
.I can create a PR for this behaviour if you want.
The text was updated successfully, but these errors were encountered: