A pure Javascript library for code evalutation in limited and isolated context
First install as dependencies by your package manager
npm install js-sandbox
Now you import the module js-sandbox
in your code
import Sandbox from 'js-sandbox';
Once imported you can instantiate a Sandbox
objects where to run your code.
- constructor ( dom, context )
- dom: a DOM element to use as document variable for code executed into the Sandbox.
- context: object to use as windows for code executed into the Sandbox.
- execCode ( code [, newContext ] )
- code: javascript code to execute in the Sandbox.
- newContext: a new object to use as window for code executed into the Sandbox instead of context passed to the constructor.
- execFunction ( func, args [, newContext ] )
- func: function to execute in the Sandbox.
- args: ordered array of arguments for the function.
- newContext: a new object to use as window for code executed into the Sandbox instead of context passed to the constructor.
- execMethod ( method, args, obj )
- method: the name of method to execute.
- args: ordered array of arguments for the method.
- obj: the object to use as this which prototype has method requested otherwise a
SandboxException
will be raise.