Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Add Contextify.createContext and Contextify.createScript

Similar to the `vm` API in node, this allows you to create a Contextify context like this:

  var sandbox = {};
  var context = Contextify.createContext(sandbox);

Unlike `Contextify()`, createContext does not augment the sandbox with `run`, `getGlobal` and `dispose`.

This also adds `Contextify.createScript`, similar to `vm.createScript`, which will pre-compile code and let you run it in a Contextify context later. This can have huge performance benefits, e.g. a web server that runs each request in a separate context.

  var sandbox = {};
  var context = Contextify.createContext(sandbox);
  var script = Contextify.createScript('var x = 1');
  script.runInContext(context);
  // sandbox.x === 1
latest commit 37e75282ef
@mroch mroch authored
..
Failed to load latest commit information.
contextify.js Add Contextify.createContext and Contextify.createScript
Something went wrong with that request. Please try again.