• Home
  • Raw
  • Download

Lines Matching +full:before +full:- +full:script

3 <!--introduced_in=v0.10.0-->
5 > Stability: 2 - Stable
7 <!--name=vm-->
9 <!-- source_link=lib/vm.js -->
47 ## Class: `vm.Script`
49 <!-- YAML
51 -->
53 Instances of the `vm.Script` class contain precompiled scripts that can be
56 ### `new vm.Script(code[, options])` argument
58 <!-- YAML
61 - version:
62 - v17.0.0
63 - v16.12.0
64 pr-url: https://github.com/nodejs/node/pull/40249
67 - version: v10.6.0
68 pr-url: https://github.com/nodejs/node/pull/20300
70 `script.createCachedData()`.
71 - version: v5.7.0
72 pr-url: https://github.com/nodejs/node/pull/4777
75 -->
80 by this script. **Default:** `'evalmachine.<anonymous>'`.
82 in stack traces produced by this script. **Default:** `0`.
83 * `columnOffset` {number} Specifies the first-line column number offset that
84 is displayed in stack traces produced by this script. **Default:** `0`.
92 `cachedData` property of the returned `vm.Script` instance.
95 This option is **deprecated** in favor of `script.createCachedData()`.
101 using it in a production environment. If `--experimental-vm-modules` isn't
105 * `script` {vm.Script}
115 Creating a new `vm.Script` object compiles `code` but does not run it. The
116 compiled `vm.Script` can be run later multiple times. The `code` is not bound to
117 any global object; rather, it is bound before each run, just for that run.
119 ### `script.cachedDataRejected`
121 <!-- YAML
123 -->
127 When `cachedData` is supplied to create the `vm.Script`, this value will be set
131 ### `script.createCachedData()`
133 <!-- YAML
135 -->
139 Creates a code cache that can be used with the `Script` constructor's
143 The code cache of the `Script` doesn't contain any JavaScript observable
144 states. The code cache is safe to be saved along side the script source and
145 used to construct new `Script` instances multiple times.
147 Functions in the `Script` source can be marked as lazily compiled and they are
148 not compiled at construction of the `Script`. These functions are going to be
150 metadata that V8 currently knows about the `Script` that it can use to speed up
154 const script = new vm.Script(`
162 const cacheWithoutAdd = script.createCachedData();
166 script.runInThisContext();
168 const cacheWithAdd = script.createCachedData();
172 ### `script.runInContext(contextifiedObject[, options])`
174 <!-- YAML
177 - version: v6.3.0
178 pr-url: https://github.com/nodejs/node/pull/6635
180 -->
189 before terminating execution. If execution is terminated, an [`Error`][]
194 `process.on('SIGINT')` are disabled during script execution, but continue to
196 * Returns: {any} the result of the very last statement executed in the script.
198 Runs the compiled code contained by the `vm.Script` object within the given
214 const script = new vm.Script('count += 1; name = "kitty";');
218 script.runInContext(context);
226 and corresponding threads being started, which have a non-zero performance
229 ### `script.runInNewContext([contextObject[, options]])`
231 <!-- YAML
234 - version: v14.6.0
235 pr-url: https://github.com/nodejs/node/pull/34023
237 - version: v10.0.0
238 pr-url: https://github.com/nodejs/node/pull/19016
240 - version: v6.3.0
241 pr-url: https://github.com/nodejs/node/pull/6635
243 -->
252 before terminating execution. If execution is terminated, an [`Error`][]
257 `process.on('SIGINT')` are disabled during script execution, but continue to
259 * `contextName` {string} Human-readable name of the newly created context.
276 after the script has run. They are included in the `timeout` and
278 * Returns: {any} the result of the very last statement executed in the script.
281 by the `vm.Script` object within the created context, and returns the result.
291 const script = new vm.Script('globalVar = "set"');
295 script.runInNewContext(context);
302 ### `script.runInThisContext([options])`
304 <!-- YAML
307 - version: v6.3.0
308 pr-url: https://github.com/nodejs/node/pull/6635
310 -->
317 before terminating execution. If execution is terminated, an [`Error`][]
322 `process.on('SIGINT')` are disabled during script execution, but continue to
324 * Returns: {any} the result of the very last statement executed in the script.
326 Runs the compiled code contained by the `vm.Script` within the context of the
338 const script = new vm.Script('globalVar += 1', { filename: 'myfile.vm' });
341 script.runInThisContext();
349 ### `script.sourceMapURL`
351 <!-- YAML
353 -->
357 When the script is compiled from a source that contains a source map magic
363 const script = new vm.Script(`
368 console.log(script.sourceMapURL);
375 const script = new vm.Script(`
380 console.log(script.sourceMapURL);
386 <!-- YAML
388 - v13.0.0
389 - v12.16.0
390 -->
392 > Stability: 1 - Experimental
394 This feature is only available with the `--experimental-vm-modules` command
397 The `vm.Module` class provides a low-level interface for using
398 ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`
402 Unlike `vm.Script` however, every `vm.Module` object is bound to a context from
404 in contrast with the synchronous nature of `vm.Script` objects. The use of
452 // Even top-level Modules without dependencies must be explicitly linked. The
459 // "foo" module every time it is called. In a full-fledged module system, a
524 // Even top-level Modules without dependencies must be explicitly linked. The
531 // "foo" module every time it is called. In a full-fledged module system, a
587 before terminating execution. If execution is interrupted, an [`Error`][]
592 `process.on('SIGINT')` are disabled during script execution, but continue to
601 (`module.status` is `'evaluated'`) or it will re-throw the exception that the
618 <!-- YAML
620 - version: v18.19.0
621 pr-url: https://github.com/nodejs/node/pull/50141
624 -->
641 Per ECMA-262, hosts are expected to trigger an error if an
648 Link module dependencies. This method must be called before evaluation, and
666 The linker function roughly corresponds to the implementation-defined
720 <!-- YAML
722 -->
724 > Stability: 1 - Experimental
726 This feature is only available with the `--experimental-vm-modules` command
736 <!-- YAML
738 - version:
739 - v17.0.0
740 - v16.12.0
741 pr-url: https://github.com/nodejs/node/pull/40249
744 -->
749 **Default:** `'vm:module(i)'` where `i` is a context-specific ascending
761 * `columnOffset` {integer} Specifies the first-line column number offset that
770 If `--experimental-vm-modules` isn't set, this callback will be ignored
845 <!-- YAML
847 - v13.7.0
848 - v12.17.0
849 -->
855 of times before the module has been evaluated.
858 observable states. The code cache is safe to be saved along side the script
880 <!-- YAML
882 - v13.0.0
883 - v12.16.0
884 -->
886 > Stability: 1 - Experimental
888 This feature is only available with the `--experimental-vm-modules` command
895 provide a generic interface for exposing non-JavaScript sources to ECMAScript
912 <!-- YAML
914 - v13.0.0
915 - v12.16.0
916 -->
923 **Default:** `'vm:module(i)'` where `i` is a context-specific ascending
936 <!-- YAML
938 - v13.0.0
939 - v12.16.0
940 -->
946 it is called before the module is linked, an [`ERR_VM_MODULE_STATUS`][] error
976 <!-- YAML
979 - version:
980 - v18.15.0
981 pr-url: https://github.com/nodejs/node/pull/46320
983 with the same semantics as the `vm.Script` version
985 - version:
986 - v17.0.0
987 - v16.12.0
988 pr-url: https://github.com/nodejs/node/pull/40249
991 - version: v15.9.0
992 pr-url: https://github.com/nodejs/node/pull/35431
994 - version: v14.3.0
995 pr-url: https://github.com/nodejs/node/pull/33364
998 - version:
999 - v14.1.0
1000 - v13.14.0
1001 pr-url: https://github.com/nodejs/node/pull/32985
1003 -->
1010 by this script. **Default:** `''`.
1012 in stack traces produced by this script. **Default:** `0`.
1013 * `columnOffset` {number} Specifies the first-line column number offset that
1014 is displayed in stack traces produced by this script. **Default:** `0`.
1030 considered stable. If `--experimental-vm-modules` isn't
1049 <!-- YAML
1052 - version: v14.6.0
1053 pr-url: https://github.com/nodejs/node/pull/34023
1055 - version: v10.0.0
1056 pr-url: https://github.com/nodejs/node/pull/19398
1058 - version: v10.0.0
1059 pr-url: https://github.com/nodejs/node/pull/19016
1061 -->
1065 * `name` {string} Human-readable name of the newly created context.
1082 after a script has run through [`script.runInContext()`][].
1088 [`vm.runInContext()`][] or [`script.runInContext()`][]. Inside such scripts,
1090 properties but also having the built-in objects and functions any standard
1117 window's global object, then run all `<script>` tags together within that
1125 <!-- YAML
1127 -->
1137 <!-- YAML
1139 -->
1141 > Stability: 1 - Experimental
1155 exits before the next GC). With eager execution, the GC will be started
1214 <!-- YAML
1217 - version:
1218 - v17.0.0
1219 - v16.12.0
1220 pr-url: https://github.com/nodejs/node/pull/40249
1223 - version: v6.3.0
1224 pr-url: https://github.com/nodejs/node/pull/6635
1226 -->
1233 by this script. **Default:** `'evalmachine.<anonymous>'`.
1235 in stack traces produced by this script. **Default:** `0`.
1236 * `columnOffset` {number} Specifies the first-line column number offset that
1237 is displayed in stack traces produced by this script. **Default:** `0`.
1242 before terminating execution. If execution is terminated, an [`Error`][]
1247 `process.on('SIGINT')` are disabled during script execution, but continue to
1256 using it in a production environment. If `--experimental-vm-modules` isn't
1260 * `script` {vm.Script}
1267 * Returns: {any} the result of the very last statement executed in the script.
1294 <!-- YAML
1297 - version:
1298 - v17.0.0
1299 - v16.12.0
1300 pr-url: https://github.com/nodejs/node/pull/40249
1303 - version: v14.6.0
1304 pr-url: https://github.com/nodejs/node/pull/34023
1306 - version: v10.0.0
1307 pr-url: https://github.com/nodejs/node/pull/19016
1309 - version: v6.3.0
1310 pr-url: https://github.com/nodejs/node/pull/6635
1312 -->
1319 by this script. **Default:** `'evalmachine.<anonymous>'`.
1321 in stack traces produced by this script. **Default:** `0`.
1322 * `columnOffset` {number} Specifies the first-line column number offset that
1323 is displayed in stack traces produced by this script. **Default:** `0`.
1328 before terminating execution. If execution is terminated, an [`Error`][]
1333 `process.on('SIGINT')` are disabled during script execution, but continue to
1335 * `contextName` {string} Human-readable name of the newly created context.
1357 using it in a production environment. If `--experimental-vm-modules` isn't
1361 * `script` {vm.Script}
1370 after the script has run. They are included in the `timeout` and
1372 * Returns: {any} the result of the very last statement executed in the script.
1399 <!-- YAML
1402 - version:
1403 - v17.0.0
1404 - v16.12.0
1405 pr-url: https://github.com/nodejs/node/pull/40249
1408 - version: v6.3.0
1409 pr-url: https://github.com/nodejs/node/pull/6635
1411 -->
1416 by this script. **Default:** `'evalmachine.<anonymous>'`.
1418 in stack traces produced by this script. **Default:** `0`.
1419 * `columnOffset` {number} Specifies the first-line column number offset that
1420 is displayed in stack traces produced by this script. **Default:** `0`.
1425 before terminating execution. If execution is terminated, an [`Error`][]
1430 `process.on('SIGINT')` are disabled during script execution, but continue to
1439 using it in a production environment. If `--experimental-vm-modules` isn't
1443 * `script` {vm.Script}
1450 * Returns: {any} the result of the very last statement executed in the script.
1461 <!-- eslint-disable prefer-const -->
1484 When using either [`script.runInThisContext()`][] or
1501 response.writeHead(200, { 'Content-Type': 'text/plain' });
1525 (or a newly-created object if `contextObject` is `undefined`) is associated
1557 // This is printed *before* 'entering loop' (!)
1579 before returning from `vm.runInNewContext()`, and will be interrupted
1595 [Cyclic Module Record]: https://tc39.es/ecma262/#sec-cyclic-module-records
1596 [ECMAScript Module Loader]: esm.md#modules-ecmascript-modules
1597 [Evaluate() concrete method]: https://tc39.es/ecma262/#sec-moduleevaluation
1598 [GetModuleNamespace]: https://tc39.es/ecma262/#sec-getmodulenamespace
1599 [HostResolveImportedModule]: https://tc39.es/ecma262/#sec-hostresolveimportedmodule
1600 [Link() concrete method]: https://tc39.es/ecma262/#sec-moduledeclarationlinking
1601 [Module Record]: https://www.ecma-international.org/ecma-262/#sec-abstract-module-records
1602 [Source Text Module Record]: https://tc39.es/ecma262/#sec-source-text-module-records
1603 [Synthetic Module Record]: https://heycam.github.io/webidl/#synthetic-module-records
1608 [`Error`]: errors.md#class-error
1609 [`URL`]: url.md#class-url
1610 [`eval()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
1611 [`optionsExpression`]: https://tc39.es/proposal-import-attributes/#sec-evaluate-import-call
1612 [`script.runInContext()`]: #scriptrunincontextcontextifiedobject-options
1613 [`script.runInThisContext()`]: #scriptruninthiscontextoptions
1615 [`vm.compileFunction()`]: #vmcompilefunctioncode-params-options
1616 [`vm.createContext()`]: #vmcreatecontextcontextobject-options
1617 [`vm.runInContext()`]: #vmrunincontextcode-contextifiedobject-options
1618 [`vm.runInThisContext()`]: #vmruninthiscontextcode-options
1619 [contextified]: #what-does-it-mean-to-contextify-an-object
1622 [origin]: https://developer.mozilla.org/en-US/docs/Glossary/Origin