Skip to content

Commit a60e498

Browse files
Flarnajasnell
authored andcommitted
doc: vm.runIn*Context can accept a string as options
PR-URL: #19910 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent b43866c commit a60e498

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

doc/api/vm.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ Returns `true` if the given `sandbox` object has been [contextified][] using
694694
* `code` {string} The JavaScript code to compile and run.
695695
* `contextifiedSandbox` {Object} The [contextified][] object that will be used
696696
as the `global` when the `code` is compiled and run.
697-
* `options`
697+
* `options` {Object|string}
698698
* `filename` {string} Specifies the filename used in stack traces produced
699699
by this script.
700700
* `lineOffset` {number} Specifies the line number offset that is displayed
@@ -713,6 +713,8 @@ the `contextifiedSandbox`, then returns the result. Running code does not have
713713
access to the local scope. The `contextifiedSandbox` object *must* have been
714714
previously [contextified][] using the [`vm.createContext()`][] method.
715715

716+
If `options` is a string, then it specifies the filename.
717+
716718
The following example compiles and executes different scripts using a single
717719
[contextified][] object:
718720

@@ -739,7 +741,7 @@ added: v0.3.1
739741
* `code` {string} The JavaScript code to compile and run.
740742
* `sandbox` {Object} An object that will be [contextified][]. If `undefined`, a
741743
new object will be created.
742-
* `options`
744+
* `options` {Object|string}
743745
* `filename` {string} Specifies the filename used in stack traces produced
744746
by this script.
745747
* `lineOffset` {number} Specifies the line number offset that is displayed
@@ -767,6 +769,8 @@ creates a new `sandbox` if passed as `undefined`), compiles the `code`, runs it
767769
within the context of the created context, then returns the result. Running code
768770
does not have access to the local scope.
769771

772+
If `options` is a string, then it specifies the filename.
773+
770774
The following example compiles and executes code that increments a global
771775
variable and sets a new one. These globals are contained in the `sandbox`.
772776

@@ -791,7 +795,7 @@ added: v0.3.1
791795
-->
792796

793797
* `code` {string} The JavaScript code to compile and run.
794-
* `options`
798+
* `options` {Object|string}
795799
* `filename` {string} Specifies the filename used in stack traces produced
796800
by this script.
797801
* `lineOffset` {number} Specifies the line number offset that is displayed
@@ -809,6 +813,8 @@ added: v0.3.1
809813
current `global` and returns the result. Running code does not have access to
810814
local scope, but does have access to the current `global` object.
811815

816+
If `options` is a string, then it specifies the filename.
817+
812818
The following example illustrates using both `vm.runInThisContext()` and
813819
the JavaScript [`eval()`][] function to run the same code:
814820

0 commit comments

Comments
 (0)