Skip to content

Commit 7abfb6e

Browse files
addaleaxMyles Borins
authored and
Myles Borins
committed
doc: add added: information for vm
Ref: #6578 PR-URL: #7011 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Julian Duque <[email protected]>
1 parent 3e3471f commit 7abfb6e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

doc/api/vm.md

+30
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@ JavaScript code can be compiled and run immediately or compiled, saved, and run
1414
later.
1515

1616
## Class: Script
17+
<!-- YAML
18+
added: v0.3.1
19+
-->
1720

1821
A class for holding precompiled scripts, and running them in specific sandboxes.
1922

2023
### new vm.Script(code, options)
24+
<!-- YAML
25+
added: v0.3.1
26+
-->
2127

2228
Creating a new `Script` compiles `code` but does not run it. Instead, the
2329
created `vm.Script` object represents this compiled code. This script can be run
@@ -40,6 +46,9 @@ The options when creating a script are:
4046
execution. If execution is terminated, an [`Error`][] will be thrown.
4147

4248
### script.runInContext(contextifiedSandbox[, options])
49+
<!-- YAML
50+
added: v0.3.1
51+
-->
4352

4453
Similar to [`vm.runInContext()`][] but a method of a precompiled `Script`
4554
object. `script.runInContext()` runs `script`'s compiled code in
@@ -78,6 +87,9 @@ Note that running untrusted code is a tricky business requiring great care.
7887
requires a separate process.
7988

8089
### script.runInNewContext([sandbox][, options])
90+
<!-- YAML
91+
added: v0.3.1
92+
-->
8193

8294
Similar to [`vm.runInNewContext()`][] but a method of a precompiled `Script`
8395
object. `script.runInNewContext()` contextifies `sandbox` if passed or creates a
@@ -114,6 +126,9 @@ Note that running untrusted code is a tricky business requiring great care.
114126
requires a separate process.
115127

116128
### script.runInThisContext([options])
129+
<!-- YAML
130+
added: v0.3.1
131+
-->
117132

118133
Similar to [`vm.runInThisContext()`]() but a method of a precompiled `Script`
119134
object. `script.runInThisContext()` runs `script`'s compiled code and returns
@@ -155,6 +170,9 @@ The options for running a script are:
155170
execution. If execution is terminated, an [`Error`][] will be thrown.
156171

157172
## vm.createContext([sandbox])
173+
<!-- YAML
174+
added: v0.3.1
175+
-->
158176

159177
If given a `sandbox` object, will "contextify" that sandbox so that it can be
160178
used in calls to [`vm.runInContext()`][] or [`script.runInContext()`][]. Inside
@@ -172,6 +190,9 @@ single sandbox representing a window's global object, then run all `<script>`
172190
tags together inside that sandbox.
173191

174192
## vm.isContext(sandbox)
193+
<!-- YAML
194+
added: v0.11.7
195+
-->
175196

176197
Returns whether or not a sandbox object has been contextified by calling
177198
[`vm.createContext()`][] on it.
@@ -207,6 +228,9 @@ Note that running untrusted code is a tricky business requiring great care.
207228
a separate process.
208229

209230
## vm.runInDebugContext(code)
231+
<!-- YAML
232+
added: v0.11.14
233+
-->
210234

211235
`vm.runInDebugContext()` compiles and executes `code` inside the V8 debug
212236
context. The primary use case is to get access to the V8 debug object:
@@ -224,6 +248,9 @@ implementation and may change (or even get removed) without prior warning.
224248
The debug object can also be exposed with the `--expose_debug_as=` switch.
225249

226250
## vm.runInNewContext(code[, sandbox][, options])
251+
<!-- YAML
252+
added: v0.3.1
253+
-->
227254

228255
`vm.runInNewContext()` compiles `code`, contextifies `sandbox` if passed or
229256
creates a new contextified sandbox if it's omitted, and then runs the code with
@@ -254,6 +281,9 @@ Note that running untrusted code is a tricky business requiring great care.
254281
a separate process.
255282

256283
## vm.runInThisContext(code[, options])
284+
<!-- YAML
285+
added: v0.3.1
286+
-->
257287

258288
`vm.runInThisContext()` compiles `code`, runs it and returns the result. Running
259289
code does not have access to local scope, but does have access to the current

0 commit comments

Comments
 (0)