diff options
author | isaacs <i@izs.me> | 2012-02-27 23:09:35 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-03-01 04:04:55 +0400 |
commit | 169b0820f0e214e6cd5c919d4a4b5b5c23549b8a (patch) | |
tree | 6bc0875ef51d15b7fc477c23be55cbcac842259e /doc/api | |
parent | 3c195d04f303c783b6b40ee70c7640515c814513 (diff) |
doc refactor: vm
Diffstat (limited to 'doc/api')
-rw-r--r-- | doc/api/vm.markdown | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/doc/api/vm.markdown b/doc/api/vm.markdown index 3d3c1684591..dfcf3506cd2 100644 --- a/doc/api/vm.markdown +++ b/doc/api/vm.markdown @@ -1,4 +1,6 @@ -## Executing JavaScript +# Executing JavaScript + +<!--name=vm--> You can access this module with: @@ -7,7 +9,7 @@ You can access this module with: JavaScript code can be compiled and run immediately or compiled, saved, and run later. -### vm.runInThisContext(code, [filename]) +## vm.runInThisContext(code, [filename]) `vm.runInThisContext()` compiles `code`, runs it and returns the result. Running code does not have access to local scope. `filename` is optional, it's used only @@ -37,7 +39,7 @@ In case of syntax error in `code`, `vm.runInThisContext` emits the syntax error and throws an exception. -### vm.runInNewContext(code, [sandbox], [filename]) +## vm.runInNewContext(code, [sandbox], [filename]) `vm.runInNewContext` compiles `code`, then runs it in `sandbox` and returns the result. Running code does not have access to local scope. The object `sandbox` @@ -66,7 +68,7 @@ requires a separate process. In case of syntax error in `code`, `vm.runInNewContext` emits the syntax error to stderr and throws an exception. -### vm.runInContext(code, context, [filename]) +## vm.runInContext(code, context, [filename]) `vm.runInContext` compiles `code`, then runs it in `context` and returns the result. A (V8) context comprises a global object, together with a set of @@ -100,14 +102,14 @@ requires a separate process. In case of syntax error in `code`, `vm.runInContext` emits the syntax error to stderr and throws an exception. -### vm.createContext([initSandbox]) +## vm.createContext([initSandbox]) `vm.createContext` creates a new context which is suitable for use as the 2nd argument of a subsequent call to `vm.runInContext`. A (V8) context comprises a global object together with a set of build-in objects and functions. The optional argument `initSandbox` will be shallow-copied to seed the initial contents of the global object used by the context. -### vm.createScript(code, [filename]) +## vm.createScript(code, [filename]) `createScript` compiles `code` but does not run it. Instead, it returns a `vm.Script` object representing this compiled code. This script can be run @@ -119,6 +121,10 @@ In case of syntax error in `code`, `createScript` prints the syntax error to std and throws an exception. +## Class: Script + +A class for running scripts. Returned by vm.createScript. + ### script.runInThisContext() Similar to `vm.runInThisContext` but a method of a precompiled `Script` object. |