Skip to content

Commit 169b082

Browse files
committed
doc refactor: vm
1 parent 3c195d0 commit 169b082

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

doc/api/vm.markdown

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
## Executing JavaScript
1+
# Executing JavaScript
2+
3+
<!--name=vm-->
24

35
You can access this module with:
46

@@ -7,7 +9,7 @@ You can access this module with:
79
JavaScript code can be compiled and run immediately or compiled, saved, and run later.
810

911

10-
### vm.runInThisContext(code, [filename])
12+
## vm.runInThisContext(code, [filename])
1113

1214
`vm.runInThisContext()` compiles `code`, runs it and returns the result. Running
1315
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
3739
and throws an exception.
3840

3941

40-
### vm.runInNewContext(code, [sandbox], [filename])
42+
## vm.runInNewContext(code, [sandbox], [filename])
4143

4244
`vm.runInNewContext` compiles `code`, then runs it in `sandbox` and returns the
4345
result. Running code does not have access to local scope. The object `sandbox`
@@ -66,7 +68,7 @@ requires a separate process.
6668
In case of syntax error in `code`, `vm.runInNewContext` emits the syntax error to stderr
6769
and throws an exception.
6870

69-
### vm.runInContext(code, context, [filename])
71+
## vm.runInContext(code, context, [filename])
7072

7173
`vm.runInContext` compiles `code`, then runs it in `context` and returns the
7274
result. A (V8) context comprises a global object, together with a set of
@@ -100,14 +102,14 @@ requires a separate process.
100102
In case of syntax error in `code`, `vm.runInContext` emits the syntax error to stderr
101103
and throws an exception.
102104

103-
### vm.createContext([initSandbox])
105+
## vm.createContext([initSandbox])
104106

105107
`vm.createContext` creates a new context which is suitable for use as the 2nd argument of a subsequent
106108
call to `vm.runInContext`. A (V8) context comprises a global object together with a set of
107109
build-in objects and functions. The optional argument `initSandbox` will be shallow-copied
108110
to seed the initial contents of the global object used by the context.
109111

110-
### vm.createScript(code, [filename])
112+
## vm.createScript(code, [filename])
111113

112114
`createScript` compiles `code` but does not run it. Instead, it returns a
113115
`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
119121
and throws an exception.
120122

121123

124+
## Class: Script
125+
126+
A class for running scripts. Returned by vm.createScript.
127+
122128
### script.runInThisContext()
123129

124130
Similar to `vm.runInThisContext` but a method of a precompiled `Script` object.

0 commit comments

Comments
 (0)