initial commit
[JIRC.git] / node_modules / jsdom / node_modules / contextify / lib / contextify.js
CommitLineData
39c8b14f 1var ContextifyContext = require('bindings')('contextify').ContextifyContext;
2
3module.exports = function Contextify (sandbox) {
4 if (typeof sandbox != 'object') {
5 sandbox = {};
6 }
7 var ctx = new ContextifyContext(sandbox);
8
9 sandbox.run = function () {
10 return ctx.run.apply(ctx, arguments);
11 };
12
13 sandbox.getGlobal = function () {
14 return ctx.getGlobal();
15 }
16
17 sandbox.dispose = function () {
18 sandbox.run = function () {
19 throw new Error("Called run() after dispose().");
20 };
21 sandbox.getGlobal = function () {
22 throw new Error("Called getGlobal() after dispose().");
23 };
24 sandbox.dispose = function () {
25 throw new Error("Called dispose() after dispose().");
26 };
27 ctx = null;
28 }
29 return sandbox;
30}