brianmcd/contextify — pull request #48 by mroch (2012-11-29 05:48:12+00:00)
Title: Allow precompiling scripts

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

```javascript
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.

```javascript
var sandbox = {};
var context = Contextify.createContext(sandbox);
var script = Contextify.createScript('var x = 1');
script.runInContext(context);
// sandbox.x === 1
```