@types/node 22.7.1 → 22.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node/README.md +1 -1
- node/async_hooks.d.ts +1 -1
- node/buffer.d.ts +4 -4
- node/child_process.d.ts +34 -29
- node/cluster.d.ts +2 -1
- node/console.d.ts +2 -2
- node/crypto.d.ts +3 -3
- node/dns/promises.d.ts +5 -5
- node/dns.d.ts +5 -5
- node/domain.d.ts +2 -2
- node/fs/promises.d.ts +2 -2
- node/fs.d.ts +2 -2
- node/http.d.ts +2 -2
- node/http2.d.ts +24 -24
- node/https.d.ts +9 -9
- node/module.d.ts +3 -3
- node/net.d.ts +2 -2
- node/os.d.ts +1 -1
- node/package.json +2 -2
- node/path.d.ts +1 -1
- node/perf_hooks.d.ts +19 -19
- node/punycode.d.ts +1 -1
- node/querystring.d.ts +1 -1
- node/readline/promises.d.ts +1 -1
- node/readline.d.ts +9 -9
- node/repl.d.ts +4 -4
- node/sqlite.d.ts +1 -1
- node/stream/web.d.ts +17 -17
- node/stream.d.ts +15 -15
- node/string_decoder.d.ts +3 -3
- node/test.d.ts +2 -2
- node/timers/promises.d.ts +5 -5
- node/timers.d.ts +1 -1
- node/tls.d.ts +5 -5
- node/trace_events.d.ts +4 -4
- node/tty.d.ts +1 -1
- node/url.d.ts +7 -7
- node/util.d.ts +44 -44
- node/v8.d.ts +12 -12
- node/vm.d.ts +13 -13
- node/wasi.d.ts +1 -1
- node/worker_threads.d.ts +22 -22
- node/zlib.d.ts +8 -8
node/util.d.ts
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
* it:
|
5
5
|
*
|
6
6
|
* ```js
|
7
|
-
*
|
7
|
+
* import util from 'node:util';
|
8
8
|
* ```
|
9
9
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/util.js)
|
10
10
|
*/
|
@@ -200,7 +200,7 @@ declare module "util" {
|
|
200
200
|
* timestamp.
|
201
201
|
*
|
202
202
|
* ```js
|
203
|
-
*
|
203
|
+
* import util from 'node:util';
|
204
204
|
*
|
205
205
|
* util.log('Timestamped message.');
|
206
206
|
* ```
|
@@ -287,7 +287,7 @@ declare module "util" {
|
|
287
287
|
* Circular references point to their anchor by using a reference index:
|
288
288
|
*
|
289
289
|
* ```js
|
290
|
-
*
|
290
|
+
* import { inspect } from 'node:util';
|
291
291
|
*
|
292
292
|
* const obj = {};
|
293
293
|
* obj.a = [obj];
|
@@ -305,7 +305,7 @@ declare module "util" {
|
|
305
305
|
* The following example inspects all properties of the `util` object:
|
306
306
|
*
|
307
307
|
* ```js
|
308
|
-
*
|
308
|
+
* import util from 'node:util';
|
309
309
|
*
|
310
310
|
* console.log(util.inspect(util, { showHidden: true, depth: null }));
|
311
311
|
* ```
|
@@ -313,7 +313,7 @@ declare module "util" {
|
|
313
313
|
* The following example highlights the effect of the `compact` option:
|
314
314
|
*
|
315
315
|
* ```js
|
316
|
-
*
|
316
|
+
* import util from 'node:util';
|
317
317
|
*
|
318
318
|
* const o = {
|
319
319
|
* a: [1, 2, [[
|
@@ -370,7 +370,7 @@ declare module "util" {
|
|
370
370
|
* with no remaining strong references may be garbage collected at any time.
|
371
371
|
*
|
372
372
|
* ```js
|
373
|
-
*
|
373
|
+
* import { inspect } from 'node:util';
|
374
374
|
*
|
375
375
|
* const obj = { a: 1 };
|
376
376
|
* const obj2 = { b: 2 };
|
@@ -384,8 +384,8 @@ declare module "util" {
|
|
384
384
|
* impact the result of `util.inspect()`.
|
385
385
|
*
|
386
386
|
* ```js
|
387
|
-
*
|
388
|
-
*
|
387
|
+
* import { inspect } from 'node:util';
|
388
|
+
* import assert from 'node:assert';
|
389
389
|
*
|
390
390
|
* const o1 = {
|
391
391
|
* b: [2, 3, 1],
|
@@ -412,7 +412,7 @@ declare module "util" {
|
|
412
412
|
* numbers.
|
413
413
|
*
|
414
414
|
* ```js
|
415
|
-
*
|
415
|
+
* import { inspect } from 'node:util';
|
416
416
|
*
|
417
417
|
* const thousand = 1_000;
|
418
418
|
* const million = 1_000_000;
|
@@ -459,7 +459,7 @@ declare module "util" {
|
|
459
459
|
* Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`.
|
460
460
|
*
|
461
461
|
* ```js
|
462
|
-
*
|
462
|
+
* import util from 'node:util';
|
463
463
|
*
|
464
464
|
* util.isArray([]);
|
465
465
|
* // Returns: true
|
@@ -476,7 +476,7 @@ declare module "util" {
|
|
476
476
|
* Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`.
|
477
477
|
*
|
478
478
|
* ```js
|
479
|
-
*
|
479
|
+
* import util from 'node:util';
|
480
480
|
*
|
481
481
|
* util.isRegExp(/some regexp/);
|
482
482
|
* // Returns: true
|
@@ -493,7 +493,7 @@ declare module "util" {
|
|
493
493
|
* Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
|
494
494
|
*
|
495
495
|
* ```js
|
496
|
-
*
|
496
|
+
* import util from 'node:util';
|
497
497
|
*
|
498
498
|
* util.isDate(new Date());
|
499
499
|
* // Returns: true
|
@@ -510,7 +510,7 @@ declare module "util" {
|
|
510
510
|
* Returns `true` if the given `object` is an `Error`. Otherwise, returns `false`.
|
511
511
|
*
|
512
512
|
* ```js
|
513
|
-
*
|
513
|
+
* import util from 'node:util';
|
514
514
|
*
|
515
515
|
* util.isError(new Error());
|
516
516
|
* // Returns: true
|
@@ -524,7 +524,7 @@ declare module "util" {
|
|
524
524
|
* possible to obtain an incorrect result when the `object` argument manipulates `@@toStringTag`.
|
525
525
|
*
|
526
526
|
* ```js
|
527
|
-
*
|
527
|
+
* import util from 'node:util';
|
528
528
|
* const obj = { name: 'Error', message: 'an error occurred' };
|
529
529
|
*
|
530
530
|
* util.isError(obj);
|
@@ -549,8 +549,8 @@ declare module "util" {
|
|
549
549
|
* through the `constructor.super_` property.
|
550
550
|
*
|
551
551
|
* ```js
|
552
|
-
*
|
553
|
-
*
|
552
|
+
* import util from 'node:util';
|
553
|
+
* import EventEmitter from 'node:events';
|
554
554
|
*
|
555
555
|
* function MyStream() {
|
556
556
|
* EventEmitter.call(this);
|
@@ -576,7 +576,7 @@ declare module "util" {
|
|
576
576
|
* ES6 example using `class` and `extends`:
|
577
577
|
*
|
578
578
|
* ```js
|
579
|
-
*
|
579
|
+
* import EventEmitter from 'node:events';
|
580
580
|
*
|
581
581
|
* class MyStream extends EventEmitter {
|
582
582
|
* write(data) {
|
@@ -605,7 +605,7 @@ declare module "util" {
|
|
605
605
|
* environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op.
|
606
606
|
*
|
607
607
|
* ```js
|
608
|
-
*
|
608
|
+
* import util from 'node:util';
|
609
609
|
* const debuglog = util.debuglog('foo');
|
610
610
|
*
|
611
611
|
* debuglog('hello from foo [%d]', 123);
|
@@ -624,7 +624,7 @@ declare module "util" {
|
|
624
624
|
* The `section` supports wildcard also:
|
625
625
|
*
|
626
626
|
* ```js
|
627
|
-
*
|
627
|
+
* import util from 'node:util';
|
628
628
|
* const debuglog = util.debuglog('foo-bar');
|
629
629
|
*
|
630
630
|
* debuglog('hi there, it\'s foo-bar [%d]', 2333);
|
@@ -644,7 +644,7 @@ declare module "util" {
|
|
644
644
|
* unnecessary wrapping.
|
645
645
|
*
|
646
646
|
* ```js
|
647
|
-
*
|
647
|
+
* import util from 'node:util';
|
648
648
|
* let debuglog = util.debuglog('internals', (debug) => {
|
649
649
|
* // Replace with a logging function that optimizes out
|
650
650
|
* // testing if the section is enabled
|
@@ -662,7 +662,7 @@ declare module "util" {
|
|
662
662
|
* Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
|
663
663
|
*
|
664
664
|
* ```js
|
665
|
-
*
|
665
|
+
* import util from 'node:util';
|
666
666
|
*
|
667
667
|
* util.isBoolean(1);
|
668
668
|
* // Returns: false
|
@@ -679,7 +679,7 @@ declare module "util" {
|
|
679
679
|
* Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`.
|
680
680
|
*
|
681
681
|
* ```js
|
682
|
-
*
|
682
|
+
* import util from 'node:util';
|
683
683
|
*
|
684
684
|
* util.isBuffer({ length: 0 });
|
685
685
|
* // Returns: false
|
@@ -696,7 +696,7 @@ declare module "util" {
|
|
696
696
|
* Returns `true` if the given `object` is a `Function`. Otherwise, returns `false`.
|
697
697
|
*
|
698
698
|
* ```js
|
699
|
-
*
|
699
|
+
* import util from 'node:util';
|
700
700
|
*
|
701
701
|
* function Foo() {}
|
702
702
|
* const Bar = () => {};
|
@@ -716,7 +716,7 @@ declare module "util" {
|
|
716
716
|
* Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`.
|
717
717
|
*
|
718
718
|
* ```js
|
719
|
-
*
|
719
|
+
* import util from 'node:util';
|
720
720
|
*
|
721
721
|
* util.isNull(0);
|
722
722
|
* // Returns: false
|
@@ -734,7 +734,7 @@ declare module "util" {
|
|
734
734
|
* returns `false`.
|
735
735
|
*
|
736
736
|
* ```js
|
737
|
-
*
|
737
|
+
* import util from 'node:util';
|
738
738
|
*
|
739
739
|
* util.isNullOrUndefined(0);
|
740
740
|
* // Returns: false
|
@@ -751,7 +751,7 @@ declare module "util" {
|
|
751
751
|
* Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.
|
752
752
|
*
|
753
753
|
* ```js
|
754
|
-
*
|
754
|
+
* import util from 'node:util';
|
755
755
|
*
|
756
756
|
* util.isNumber(false);
|
757
757
|
* // Returns: false
|
@@ -771,7 +771,7 @@ declare module "util" {
|
|
771
771
|
* Otherwise, returns `false`.
|
772
772
|
*
|
773
773
|
* ```js
|
774
|
-
*
|
774
|
+
* import util from 'node:util';
|
775
775
|
*
|
776
776
|
* util.isObject(5);
|
777
777
|
* // Returns: false
|
@@ -790,7 +790,7 @@ declare module "util" {
|
|
790
790
|
* Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`.
|
791
791
|
*
|
792
792
|
* ```js
|
793
|
-
*
|
793
|
+
* import util from 'node:util';
|
794
794
|
*
|
795
795
|
* util.isPrimitive(5);
|
796
796
|
* // Returns: true
|
@@ -819,7 +819,7 @@ declare module "util" {
|
|
819
819
|
* Returns `true` if the given `object` is a `string`. Otherwise, returns `false`.
|
820
820
|
*
|
821
821
|
* ```js
|
822
|
-
*
|
822
|
+
* import util from 'node:util';
|
823
823
|
*
|
824
824
|
* util.isString('');
|
825
825
|
* // Returns: true
|
@@ -838,7 +838,7 @@ declare module "util" {
|
|
838
838
|
* Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`.
|
839
839
|
*
|
840
840
|
* ```js
|
841
|
-
*
|
841
|
+
* import util from 'node:util';
|
842
842
|
*
|
843
843
|
* util.isSymbol(5);
|
844
844
|
* // Returns: false
|
@@ -855,7 +855,7 @@ declare module "util" {
|
|
855
855
|
* Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`.
|
856
856
|
*
|
857
857
|
* ```js
|
858
|
-
*
|
858
|
+
* import util from 'node:util';
|
859
859
|
*
|
860
860
|
* const foo = undefined;
|
861
861
|
* util.isUndefined(5);
|
@@ -874,7 +874,7 @@ declare module "util" {
|
|
874
874
|
* such a way that it is marked as deprecated.
|
875
875
|
*
|
876
876
|
* ```js
|
877
|
-
*
|
877
|
+
* import util from 'node:util';
|
878
878
|
*
|
879
879
|
* exports.obsoleteFunction = util.deprecate(() => {
|
880
880
|
* // Do something here.
|
@@ -890,7 +890,7 @@ declare module "util" {
|
|
890
890
|
* the warning will be emitted only once for that `code`.
|
891
891
|
*
|
892
892
|
* ```js
|
893
|
-
*
|
893
|
+
* import util from 'node:util';
|
894
894
|
*
|
895
895
|
* const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001');
|
896
896
|
* const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001');
|
@@ -944,7 +944,7 @@ declare module "util" {
|
|
944
944
|
* first argument will be the rejection reason (or `null` if the `Promise` resolved), and the second argument will be the resolved value.
|
945
945
|
*
|
946
946
|
* ```js
|
947
|
-
*
|
947
|
+
* import util from 'node:util';
|
948
948
|
*
|
949
949
|
* async function fn() {
|
950
950
|
* return 'hello world';
|
@@ -1070,8 +1070,8 @@ declare module "util" {
|
|
1070
1070
|
* that returns promises.
|
1071
1071
|
*
|
1072
1072
|
* ```js
|
1073
|
-
*
|
1074
|
-
*
|
1073
|
+
* import util from 'node:util';
|
1074
|
+
* import fs from 'node:fs';
|
1075
1075
|
*
|
1076
1076
|
* const stat = util.promisify(fs.stat);
|
1077
1077
|
* stat('.').then((stats) => {
|
@@ -1084,8 +1084,8 @@ declare module "util" {
|
|
1084
1084
|
* Or, equivalently using `async function`s:
|
1085
1085
|
*
|
1086
1086
|
* ```js
|
1087
|
-
*
|
1088
|
-
*
|
1087
|
+
* import util from 'node:util';
|
1088
|
+
* import fs from 'node:fs';
|
1089
1089
|
*
|
1090
1090
|
* const stat = util.promisify(fs.stat);
|
1091
1091
|
*
|
@@ -1108,7 +1108,7 @@ declare module "util" {
|
|
1108
1108
|
* work as expected unless handled specially:
|
1109
1109
|
*
|
1110
1110
|
* ```js
|
1111
|
-
*
|
1111
|
+
* import util from 'node:util';
|
1112
1112
|
*
|
1113
1113
|
* class Foo {
|
1114
1114
|
* constructor() {
|
@@ -1178,7 +1178,7 @@ declare module "util" {
|
|
1178
1178
|
* Given an example `.env` file:
|
1179
1179
|
*
|
1180
1180
|
* ```js
|
1181
|
-
*
|
1181
|
+
* import { parseEnv } from 'node:util';
|
1182
1182
|
*
|
1183
1183
|
* parseEnv('HELLO=world\nHELLO=oh my\n');
|
1184
1184
|
* // Returns: { HELLO: 'oh my' }
|
@@ -1247,7 +1247,7 @@ declare module "util" {
|
|
1247
1247
|
* This function returns a formatted text considering the `format` passed.
|
1248
1248
|
*
|
1249
1249
|
* ```js
|
1250
|
-
*
|
1250
|
+
* import { styleText } from 'node:util';
|
1251
1251
|
* const errorMessage = styleText('red', 'Error! Error!');
|
1252
1252
|
* console.log(errorMessage);
|
1253
1253
|
* ```
|
@@ -1383,7 +1383,7 @@ declare module "util" {
|
|
1383
1383
|
import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from "util";
|
1384
1384
|
global {
|
1385
1385
|
/**
|
1386
|
-
* `TextDecoder` class is a global reference for `
|
1386
|
+
* `TextDecoder` class is a global reference for `import { TextDecoder } from 'node:util'`
|
1387
1387
|
* https://nodejs.org/api/globals.html#textdecoder
|
1388
1388
|
* @since v11.0.0
|
1389
1389
|
*/
|
@@ -1393,7 +1393,7 @@ declare module "util" {
|
|
1393
1393
|
} ? TextDecoder
|
1394
1394
|
: typeof _TextDecoder;
|
1395
1395
|
/**
|
1396
|
-
* `TextEncoder` class is a global reference for `
|
1396
|
+
* `TextEncoder` class is a global reference for `import { TextEncoder } from 'node:util'`
|
1397
1397
|
* https://nodejs.org/api/globals.html#textencoder
|
1398
1398
|
* @since v11.0.0
|
1399
1399
|
*/
|
@@ -2087,7 +2087,7 @@ declare module "util/types" {
|
|
2087
2087
|
* which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false` for these errors:
|
2088
2088
|
*
|
2089
2089
|
* ```js
|
2090
|
-
*
|
2090
|
+
* import vm from 'node:vm';
|
2091
2091
|
* const context = vm.createContext({});
|
2092
2092
|
* const myError = vm.runInContext('new Error()', context);
|
2093
2093
|
* console.log(util.types.isNativeError(myError)); // true
|
node/v8.d.ts
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* The `node:v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using:
|
3
3
|
*
|
4
4
|
* ```js
|
5
|
-
*
|
5
|
+
* import v8 from 'node:v8';
|
6
6
|
* ```
|
7
7
|
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/v8.js)
|
8
8
|
*/
|
@@ -176,7 +176,7 @@ declare module "v8" {
|
|
176
176
|
*
|
177
177
|
* ```js
|
178
178
|
* // Print GC events to stdout for one minute.
|
179
|
-
*
|
179
|
+
* import v8 from 'node:v8';
|
180
180
|
* v8.setFlagsFromString('--trace_gc');
|
181
181
|
* setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
|
182
182
|
* ```
|
@@ -243,7 +243,7 @@ declare module "v8" {
|
|
243
243
|
*
|
244
244
|
* ```js
|
245
245
|
* // Print heap snapshot to the console
|
246
|
-
*
|
246
|
+
* import v8 from 'node:v8';
|
247
247
|
* const stream = v8.getHeapSnapshot();
|
248
248
|
* stream.pipe(process.stdout);
|
249
249
|
* ```
|
@@ -268,12 +268,12 @@ declare module "v8" {
|
|
268
268
|
* for a duration depending on the heap size.
|
269
269
|
*
|
270
270
|
* ```js
|
271
|
-
*
|
272
|
-
*
|
271
|
+
* import { writeHeapSnapshot } from 'node:v8';
|
272
|
+
* import {
|
273
273
|
* Worker,
|
274
274
|
* isMainThread,
|
275
275
|
* parentPort,
|
276
|
-
* }
|
276
|
+
* } from 'node:worker_threads';
|
277
277
|
*
|
278
278
|
* if (isMainThread) {
|
279
279
|
* const worker = new Worker(__filename);
|
@@ -550,7 +550,7 @@ declare module "v8" {
|
|
550
550
|
* Here's an example.
|
551
551
|
*
|
552
552
|
* ```js
|
553
|
-
*
|
553
|
+
* import { GCProfiler } from 'node:v8';
|
554
554
|
* const profiler = new GCProfiler();
|
555
555
|
* profiler.start();
|
556
556
|
* setTimeout(() => {
|
@@ -736,12 +736,12 @@ declare module "v8" {
|
|
736
736
|
* ```js
|
737
737
|
* 'use strict';
|
738
738
|
*
|
739
|
-
*
|
740
|
-
*
|
741
|
-
*
|
742
|
-
*
|
739
|
+
* import fs from 'node:fs';
|
740
|
+
* import zlib from 'node:zlib';
|
741
|
+
* import path from 'node:path';
|
742
|
+
* import assert from 'node:assert';
|
743
743
|
*
|
744
|
-
*
|
744
|
+
* import v8 from 'node:v8';
|
745
745
|
*
|
746
746
|
* class BookShelf {
|
747
747
|
* storage = new Map();
|
node/vm.d.ts
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
* code are reflected in the context object.
|
18
18
|
*
|
19
19
|
* ```js
|
20
|
-
*
|
20
|
+
* import vm from 'node:vm';
|
21
21
|
*
|
22
22
|
* const x = 1;
|
23
23
|
*
|
@@ -203,7 +203,7 @@ declare module "vm" {
|
|
203
203
|
* The globals are contained in the `context` object.
|
204
204
|
*
|
205
205
|
* ```js
|
206
|
-
*
|
206
|
+
* import vm from 'node:vm';
|
207
207
|
*
|
208
208
|
* const context = {
|
209
209
|
* animal: 'cat',
|
@@ -239,7 +239,7 @@ declare module "vm" {
|
|
239
239
|
* contained within each individual `context`.
|
240
240
|
*
|
241
241
|
* ```js
|
242
|
-
*
|
242
|
+
* import vm from 'node:vm';
|
243
243
|
*
|
244
244
|
* const script = new vm.Script('globalVar = "set"');
|
245
245
|
*
|
@@ -264,7 +264,7 @@ declare module "vm" {
|
|
264
264
|
* executes that code multiple times:
|
265
265
|
*
|
266
266
|
* ```js
|
267
|
-
*
|
267
|
+
* import vm from 'node:vm';
|
268
268
|
*
|
269
269
|
* global.globalVar = 0;
|
270
270
|
*
|
@@ -357,7 +357,7 @@ declare module "vm" {
|
|
357
357
|
* variables will remain unchanged.
|
358
358
|
*
|
359
359
|
* ```js
|
360
|
-
*
|
360
|
+
* import vm from 'node:vm';
|
361
361
|
*
|
362
362
|
* global.globalVar = 3;
|
363
363
|
*
|
@@ -404,7 +404,7 @@ declare module "vm" {
|
|
404
404
|
* The following example compiles and executes different scripts using a single `contextified` object:
|
405
405
|
*
|
406
406
|
* ```js
|
407
|
-
*
|
407
|
+
* import vm from 'node:vm';
|
408
408
|
*
|
409
409
|
* const contextObject = { globalVar: 1 };
|
410
410
|
* vm.createContext(contextObject);
|
@@ -433,7 +433,7 @@ declare module "vm" {
|
|
433
433
|
* variable and sets a new one. These globals are contained in the `contextObject`.
|
434
434
|
*
|
435
435
|
* ```js
|
436
|
-
*
|
436
|
+
* import vm from 'node:vm';
|
437
437
|
*
|
438
438
|
* const contextObject = {
|
439
439
|
* animal: 'cat',
|
@@ -465,7 +465,7 @@ declare module "vm" {
|
|
465
465
|
* the JavaScript [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) function to run the same code:
|
466
466
|
*
|
467
467
|
* ```js
|
468
|
-
*
|
468
|
+
* import vm from 'node:vm';
|
469
469
|
* let localVar = 'initial value';
|
470
470
|
*
|
471
471
|
* const vmResult = vm.runInThisContext('localVar = "vm";');
|
@@ -487,16 +487,16 @@ declare module "vm" {
|
|
487
487
|
* context. The code passed to this VM context will have its own isolated scope.
|
488
488
|
*
|
489
489
|
* In order to run a simple web server using the `node:http` module the code passed
|
490
|
-
* to the context must either
|
490
|
+
* to the context must either import `node:http` on its own, or have a
|
491
491
|
* reference to the `node:http` module passed to it. For instance:
|
492
492
|
*
|
493
493
|
* ```js
|
494
494
|
* 'use strict';
|
495
|
-
*
|
495
|
+
* import vm from 'node:vm';
|
496
496
|
*
|
497
497
|
* const code = `
|
498
498
|
* ((require) => {
|
499
|
-
*
|
499
|
+
* const http = require('node:http');
|
500
500
|
*
|
501
501
|
* http.createServer((request, response) => {
|
502
502
|
* response.writeHead(200, { 'Content-Type': 'text/plain' });
|
@@ -547,7 +547,7 @@ declare module "vm" {
|
|
547
547
|
* the memory occupied by each heap space in the current V8 instance.
|
548
548
|
*
|
549
549
|
* ```js
|
550
|
-
*
|
550
|
+
* import vm from 'node:vm';
|
551
551
|
* // Measure the memory used by the main context.
|
552
552
|
* vm.measureMemory({ mode: 'summary' })
|
553
553
|
* // This is the same as vm.measureMemory()
|
@@ -853,7 +853,7 @@ declare module "vm" {
|
|
853
853
|
* module graphs.
|
854
854
|
*
|
855
855
|
* ```js
|
856
|
-
*
|
856
|
+
* import vm from 'node:vm';
|
857
857
|
*
|
858
858
|
* const source = '{ "a": 1 }';
|
859
859
|
* const module = new vm.SyntheticModule(['default'], function() {
|