summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/api/script.markdown10
-rw-r--r--lib/javascript.js3
-rw-r--r--test/simple/test-querystring.js2
-rw-r--r--test/simple/test-script-context.js2
-rw-r--r--test/simple/test-script-new.js2
-rw-r--r--test/simple/test-script-static-context.js2
-rw-r--r--test/simple/test-script-static-new.js2
-rw-r--r--test/simple/test-script-static-this.js2
-rw-r--r--test/simple/test-script-this.js2
9 files changed, 15 insertions, 12 deletions
diff --git a/doc/api/script.markdown b/doc/api/script.markdown
index a0983fa8e..7f87e5568 100644
--- a/doc/api/script.markdown
+++ b/doc/api/script.markdown
@@ -2,7 +2,7 @@
`Script` class compiles and runs JavaScript code. You can access this class with:
- var Script = process.binding('evals').Script;
+ var Script = require('javascript').Script;
New JavaScript code can be compiled and run immediately or compiled, saved, and run later.
@@ -16,7 +16,7 @@ Example of using `Script.runInThisContext` and `eval` to run the same code:
var localVar = 123,
usingscript, evaled,
- Script = process.binding('evals').Script;
+ Script = require('javascript').Script;
usingscript = Script.runInThisContext('localVar = 1;',
'myfile.js');
@@ -47,7 +47,7 @@ Example: compile and execute code that increments a global variable and sets a n
These globals are contained in the sandbox.
var util = require('util'),
- Script = process.binding('evals').Script,
+ Script = require('javascript').Script,
sandbox = {
animal: 'cat',
count: 2
@@ -88,7 +88,7 @@ Running code does not have access to local scope, but does have access to the `g
Example of using `script.runInThisContext` to compile code once and run it multiple times:
- var Script = process.binding('evals').Script,
+ var Script = require('javascript').Script,
scriptObj, i;
globalVar = 0;
@@ -114,7 +114,7 @@ Example: compile code that increments a global variable and sets one, then execu
These globals are contained in the sandbox.
var util = require('util'),
- Script = process.binding('evals').Script,
+ Script = require('javascript').Script,
scriptObj, i,
sandbox = {
animal: 'cat',
diff --git a/lib/javascript.js b/lib/javascript.js
new file mode 100644
index 000000000..9d5d9845a
--- /dev/null
+++ b/lib/javascript.js
@@ -0,0 +1,3 @@
+var binding = process.binding('evals');
+
+exports.Script = binding.Script;
diff --git a/test/simple/test-querystring.js b/test/simple/test-querystring.js
index 680f828c6..27fe388ed 100644
--- a/test/simple/test-querystring.js
+++ b/test/simple/test-querystring.js
@@ -55,7 +55,7 @@ var qsWeirdObjects = [
];
}
-var Script = process.binding('evals').Script;
+var Script = require('javascript').Script;
var foreignObject = Script.runInContext('({"foo": ["bar", "baz"]})', Script.createContext());
var qsNoMungeTestCases = [
diff --git a/test/simple/test-script-context.js b/test/simple/test-script-context.js
index 40a46c700..610ceaf16 100644
--- a/test/simple/test-script-context.js
+++ b/test/simple/test-script-context.js
@@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
-var Script = process.binding('evals').Script;
+var Script = require('javascript').Script;
var script = new Script('"passed";');
common.debug('run in a new empty context');
diff --git a/test/simple/test-script-new.js b/test/simple/test-script-new.js
index f622aa503..ff5ae3ce0 100644
--- a/test/simple/test-script-new.js
+++ b/test/simple/test-script-new.js
@@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
-var Script = process.binding('evals').Script;
+var Script = require('javascript').Script;
common.debug('run a string');
var script = new Script('"passed";');
common.debug('script created');
diff --git a/test/simple/test-script-static-context.js b/test/simple/test-script-static-context.js
index 90df3c2df..a8c106e4f 100644
--- a/test/simple/test-script-static-context.js
+++ b/test/simple/test-script-static-context.js
@@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
-var Script = process.binding('evals').Script;
+var Script = require('javascript').Script;
common.debug('run in a new empty context');
var context = Script.createContext();
diff --git a/test/simple/test-script-static-new.js b/test/simple/test-script-static-new.js
index 0046f0479..a8f12090a 100644
--- a/test/simple/test-script-static-new.js
+++ b/test/simple/test-script-static-new.js
@@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
-var Script = process.binding('evals').Script;
+var Script = require('javascript').Script;
common.debug('run a string');
var result = Script.runInNewContext('"passed";');
diff --git a/test/simple/test-script-static-this.js b/test/simple/test-script-static-this.js
index ed1a631ae..cd48b709e 100644
--- a/test/simple/test-script-static-this.js
+++ b/test/simple/test-script-static-this.js
@@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
-var Script = process.binding('evals').Script;
+var Script = require('javascript').Script;
common.debug('run a string');
var result = Script.runInThisContext('"passed";');
diff --git a/test/simple/test-script-this.js b/test/simple/test-script-this.js
index 0cc8ce931..2e071a912 100644
--- a/test/simple/test-script-this.js
+++ b/test/simple/test-script-this.js
@@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
-var Script = process.binding('evals').Script;
+var Script = require('javascript').Script;
common.debug('run a string');
var script = new Script('"passed";');