Skip to content

Commit

Permalink
Use require('javascript') instead of process.binding('evals')
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Nov 13, 2010
1 parent bc0118e commit d787a44
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 12 deletions.
10 changes: 5 additions & 5 deletions doc/api/script.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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');
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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',
Expand Down
3 changes: 3 additions & 0 deletions lib/javascript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var binding = process.binding('evals');

exports.Script = binding.Script;
2 changes: 1 addition & 1 deletion test/simple/test-querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-script-context.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-script-new.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-script-static-context.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-script-static-new.js
Original file line number Diff line number Diff line change
@@ -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";');
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-script-static-this.js
Original file line number Diff line number Diff line change
@@ -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";');
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-script-this.js
Original file line number Diff line number Diff line change
@@ -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";');
Expand Down

0 comments on commit d787a44

Please sign in to comment.