@@ -14,10 +14,16 @@ JavaScript code can be compiled and run immediately or compiled, saved, and run
1414later.
1515
1616## Class: Script
17+ <!-- YAML
18+ added: v0.3.1
19+ -->
1720
1821A 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
2228Creating a new ` Script ` compiles ` code ` but does not run it. Instead, the
2329created ` 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
4453Similar to [ ` vm.runInContext() ` ] [ ] but a method of a precompiled ` Script `
4554object. ` script.runInContext() ` runs ` script ` 's compiled code in
@@ -78,6 +87,9 @@ Note that running untrusted code is a tricky business requiring great care.
7887requires a separate process.
7988
8089### script.runInNewContext([ sandbox] [ , options ] )
90+ <!-- YAML
91+ added: v0.3.1
92+ -->
8193
8294Similar to [ ` vm.runInNewContext() ` ] [ ] but a method of a precompiled ` Script `
8395object. ` 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.
114126requires a separate process.
115127
116128### script.runInThisContext([ options] )
129+ <!-- YAML
130+ added: v0.3.1
131+ -->
117132
118133Similar to [ ` vm.runInThisContext() ` ] ( ) but a method of a precompiled ` Script `
119134object. ` 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
159177If given a ` sandbox ` object, will "contextify" that sandbox so that it can be
160178used 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>`
172190tags together inside that sandbox.
173191
174192## vm.isContext(sandbox)
193+ <!-- YAML
194+ added: v0.11.7
195+ -->
175196
176197Returns 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.
207228a 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
212236context. 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.
224248The 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
229256creates 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.
254281a 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
259289code does not have access to local scope, but does have access to the current
0 commit comments