mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
Use require('javascript') instead of process.binding('evals')
This commit is contained in:
1 parent
bc0118e519
commit
d787a444c5
9 files changed
+15
-12
No files matched your search
@@ -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',
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
var binding = process.binding('evals');
|
||||
|
||||
exports.Script = binding.Script;
|
||||
@@ -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 = [
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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";');
|
||||
|
||||
@@ -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";');
|
||||
|
||||
@@ -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";');
|
||||
|
||||
Reference in new issue
Block a user