@types/node 18.15.5 → 18.15.10
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/diagnostics_channel.d.ts +39 -0
- node/dns.d.ts +1 -1
- node/http.d.ts +7 -0
- node/http2.d.ts +0 -1
- node/package.json +2 -2
- node/process.d.ts +6 -0
- node/test.d.ts +99 -31
- node/ts4.8/diagnostics_channel.d.ts +40 -1
- node/ts4.8/dns.d.ts +1 -1
- node/ts4.8/http2.d.ts +0 -1
- node/ts4.8/process.d.ts +6 -0
- node/ts4.8/test.d.ts +99 -31
- node/ts4.8/v8.d.ts +51 -0
- node/ts4.8/vm.d.ts +146 -11
- node/v8.d.ts +51 -0
- node/vm.d.ts +146 -11
node/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Sat, 25 Mar 2023 22:33:05 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
|
|
14
14
|
|
node/diagnostics_channel.d.ts
CHANGED
|
@@ -58,6 +58,45 @@ declare module 'diagnostics_channel' {
|
|
|
58
58
|
*/
|
|
59
59
|
function channel(name: string | symbol): Channel;
|
|
60
60
|
type ChannelListener = (message: unknown, name: string | symbol) => void;
|
|
61
|
+
/**
|
|
62
|
+
* Register a message handler to subscribe to this channel. This message handler will be run synchronously
|
|
63
|
+
* whenever a message is published to the channel. Any errors thrown in the message handler will
|
|
64
|
+
* trigger an 'uncaughtException'.
|
|
65
|
+
*
|
|
66
|
+
* ```js
|
|
67
|
+
* import diagnostics_channel from 'diagnostics_channel';
|
|
68
|
+
*
|
|
69
|
+
* diagnostics_channel.subscribe('my-channel', (message, name) => {
|
|
70
|
+
* // Received data
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @since v18.7.0, v16.17.0
|
|
75
|
+
* @param name The channel name
|
|
76
|
+
* @param onMessage The handler to receive channel messages
|
|
77
|
+
*/
|
|
78
|
+
function subscribe(name: string | symbol, onMessage: ChannelListener): void;
|
|
79
|
+
/**
|
|
80
|
+
* Remove a message handler previously registered to this channel with diagnostics_channel.subscribe(name, onMessage).
|
|
81
|
+
*
|
|
82
|
+
* ```js
|
|
83
|
+
* import diagnostics_channel from 'diagnostics_channel';
|
|
84
|
+
*
|
|
85
|
+
* function onMessage(message, name) {
|
|
86
|
+
* // Received data
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* diagnostics_channel.subscribe('my-channel', onMessage);
|
|
90
|
+
*
|
|
91
|
+
* diagnostics_channel.unsubscribe('my-channel', onMessage);
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @since v18.7.0, v16.17.0
|
|
95
|
+
* @param name The channel name
|
|
96
|
+
* @param onMessage The previous subscribed handler to remove
|
|
97
|
+
* @returns `true` if the handler was found, `false` otherwise
|
|
98
|
+
*/
|
|
99
|
+
function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean;
|
|
61
100
|
/**
|
|
62
101
|
* The class `Channel` represents an individual named channel within the data
|
|
63
102
|
* pipeline. It is use to track subscribers and to publish messages when there
|
node/dns.d.ts
CHANGED
node/http.d.ts
CHANGED
|
@@ -144,6 +144,7 @@ declare module 'http' {
|
|
|
144
144
|
socketPath?: string | undefined;
|
|
145
145
|
timeout?: number | undefined;
|
|
146
146
|
uniqueHeaders?: Array<string | string[]> | undefined;
|
|
147
|
+
joinDuplicateHeaders?: boolean;
|
|
147
148
|
}
|
|
148
149
|
interface ServerOptions<
|
|
149
150
|
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
|
@@ -164,6 +165,12 @@ declare module 'http' {
|
|
|
164
165
|
* @since v18.0.0
|
|
165
166
|
*/
|
|
166
167
|
requestTimeout?: number | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* It joins the field line values of multiple headers in a request with `, ` instead of discarding the duplicates.
|
|
170
|
+
* @default false
|
|
171
|
+
* @since v18.14.0
|
|
172
|
+
*/
|
|
173
|
+
joinDuplicateHeaders?: boolean;
|
|
167
174
|
/**
|
|
168
175
|
* The number of milliseconds of inactivity a server needs to wait for additional incoming data,
|
|
169
176
|
* after it has finished writing the last response, before a socket will be destroyed.
|
node/http2.d.ts
CHANGED
|
@@ -1053,7 +1053,6 @@ declare module 'http2' {
|
|
|
1053
1053
|
*/
|
|
1054
1054
|
unknownProtocolTimeout?: number | undefined;
|
|
1055
1055
|
selectPadding?(frameLen: number, maxFrameLen: number): number;
|
|
1056
|
-
createConnection?(authority: url.URL, option: SessionOptions): stream.Duplex;
|
|
1057
1056
|
}
|
|
1058
1057
|
export interface ClientSessionOptions extends SessionOptions {
|
|
1059
1058
|
maxReservedRemoteStreams?: number | undefined;
|
node/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "18.15.
|
|
3
|
+
"version": "18.15.10",
|
|
4
4
|
"description": "TypeScript definitions for Node.js",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -232,6 +232,6 @@
|
|
|
232
232
|
},
|
|
233
233
|
"scripts": {},
|
|
234
234
|
"dependencies": {},
|
|
235
|
-
"typesPublisherContentHash": "
|
|
235
|
+
"typesPublisherContentHash": "d968764271bc711c7d024195dad3ccfa3e82756092d060a8df0f5a57a517c842",
|
|
236
236
|
"typeScriptVersion": "4.3"
|
|
237
237
|
}
|
node/process.d.ts
CHANGED
|
@@ -1089,6 +1089,12 @@ declare module 'process' {
|
|
|
1089
1089
|
*/
|
|
1090
1090
|
mainModule?: Module | undefined;
|
|
1091
1091
|
memoryUsage: MemoryUsageFn;
|
|
1092
|
+
/**
|
|
1093
|
+
* Gets the amount of memory available to the process (in bytes) based on
|
|
1094
|
+
* limits imposed by the OS. If there is no such constraint, or the constraint
|
|
1095
|
+
* is unknown, `undefined` is returned.
|
|
1096
|
+
*/
|
|
1097
|
+
constrainedMemory(): number | undefined;
|
|
1092
1098
|
/**
|
|
1093
1099
|
* The `process.cpuUsage()` method returns the user and system CPU time usage of
|
|
1094
1100
|
* the current process, in an object with properties `user` and `system`, whose
|
node/test.d.ts
CHANGED
|
@@ -7,16 +7,16 @@ declare module 'node:test' {
|
|
|
7
7
|
* Programmatically start the test runner.
|
|
8
8
|
* @since v18.9.0
|
|
9
9
|
* @param options Configuration options for running tests.
|
|
10
|
-
* @returns A {@link
|
|
10
|
+
* @returns A {@link TestsStream} that emits events about the test execution.
|
|
11
11
|
*/
|
|
12
|
-
function run(options?: RunOptions):
|
|
12
|
+
function run(options?: RunOptions): TestsStream;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The `test()` function is the value imported from the test module. Each invocation of this
|
|
16
|
-
* function results in the
|
|
16
|
+
* function results in reporting the test to the {@link TestsStream}.
|
|
17
17
|
*
|
|
18
18
|
* The {@link TestContext} object passed to the fn argument can be used to perform actions
|
|
19
|
-
* related to the current test. Examples include skipping the test, adding additional
|
|
19
|
+
* related to the current test. Examples include skipping the test, adding additional
|
|
20
20
|
* diagnostic information, or creating subtests.
|
|
21
21
|
*
|
|
22
22
|
* `test()` returns a {@link Promise} that resolves once the test completes. The return value
|
|
@@ -158,54 +158,88 @@ declare module 'node:test' {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
* A successful call of the `run()` method will return a new `
|
|
162
|
-
* streaming a
|
|
163
|
-
* `
|
|
161
|
+
* A successful call of the `run()` method will return a new `TestsStream` object,
|
|
162
|
+
* streaming a series of events representing the execution of the tests.
|
|
163
|
+
* `TestsStream` will emit events in the order of the tests' definitions.
|
|
164
164
|
* @since v18.9.0
|
|
165
165
|
*/
|
|
166
|
-
interface
|
|
167
|
-
addListener(event: 'test:diagnostic', listener: (
|
|
166
|
+
interface TestsStream extends NodeJS.ReadableStream {
|
|
167
|
+
addListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
|
|
168
168
|
addListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
169
169
|
addListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
170
|
+
addListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
|
|
171
|
+
addListener(event: 'test:start', listener: (data: TestStart) => void): this;
|
|
170
172
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
171
|
-
emit(event: 'test:diagnostic',
|
|
173
|
+
emit(event: 'test:diagnostic', data: DiagnosticData): boolean;
|
|
172
174
|
emit(event: 'test:fail', data: TestFail): boolean;
|
|
173
175
|
emit(event: 'test:pass', data: TestPass): boolean;
|
|
176
|
+
emit(event: 'test:plan', data: TestPlan): boolean;
|
|
177
|
+
emit(event: 'test:start', data: TestStart): boolean;
|
|
174
178
|
emit(event: string | symbol, ...args: any[]): boolean;
|
|
175
|
-
on(event: 'test:diagnostic', listener: (
|
|
179
|
+
on(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
|
|
176
180
|
on(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
177
181
|
on(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
182
|
+
on(event: 'test:plan', listener: (data: TestPlan) => void): this;
|
|
183
|
+
on(event: 'test:start', listener: (data: TestStart) => void): this;
|
|
178
184
|
on(event: string, listener: (...args: any[]) => void): this;
|
|
179
|
-
once(event: 'test:diagnostic', listener: (
|
|
185
|
+
once(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
|
|
180
186
|
once(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
181
187
|
once(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
188
|
+
once(event: 'test:plan', listener: (data: TestPlan) => void): this;
|
|
189
|
+
once(event: 'test:start', listener: (data: TestStart) => void): this;
|
|
182
190
|
once(event: string, listener: (...args: any[]) => void): this;
|
|
183
|
-
prependListener(event: 'test:diagnostic', listener: (
|
|
191
|
+
prependListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
|
|
184
192
|
prependListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
185
193
|
prependListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
194
|
+
prependListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
|
|
195
|
+
prependListener(event: 'test:start', listener: (data: TestStart) => void): this;
|
|
186
196
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
187
|
-
prependOnceListener(event: 'test:diagnostic', listener: (
|
|
197
|
+
prependOnceListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
|
|
188
198
|
prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
189
199
|
prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
200
|
+
prependOnceListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
|
|
201
|
+
prependOnceListener(event: 'test:start', listener: (data: TestStart) => void): this;
|
|
190
202
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
191
203
|
}
|
|
192
204
|
|
|
193
|
-
interface
|
|
205
|
+
interface DiagnosticData {
|
|
206
|
+
/**
|
|
207
|
+
* The diagnostic message.
|
|
208
|
+
*/
|
|
209
|
+
message: string;
|
|
210
|
+
|
|
194
211
|
/**
|
|
195
|
-
* The test
|
|
212
|
+
* The nesting level of the test.
|
|
196
213
|
*/
|
|
197
|
-
|
|
214
|
+
nesting: number;
|
|
215
|
+
}
|
|
198
216
|
|
|
217
|
+
interface TestFail {
|
|
199
218
|
/**
|
|
200
|
-
*
|
|
219
|
+
* Additional execution metadata.
|
|
201
220
|
*/
|
|
202
|
-
|
|
221
|
+
details: {
|
|
222
|
+
/**
|
|
223
|
+
* The duration of the test in milliseconds.
|
|
224
|
+
*/
|
|
225
|
+
duration: number;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The error thrown by the test.
|
|
229
|
+
*/
|
|
230
|
+
error: Error;
|
|
231
|
+
};
|
|
203
232
|
|
|
204
233
|
/**
|
|
205
234
|
* The test name.
|
|
206
235
|
*/
|
|
207
236
|
name: string;
|
|
208
237
|
|
|
238
|
+
/**
|
|
239
|
+
* The nesting level of the test.
|
|
240
|
+
*/
|
|
241
|
+
nesting: number;
|
|
242
|
+
|
|
209
243
|
/**
|
|
210
244
|
* The ordinal number of the test.
|
|
211
245
|
*/
|
|
@@ -214,25 +248,35 @@ declare module 'node:test' {
|
|
|
214
248
|
/**
|
|
215
249
|
* Present if `context.todo` is called.
|
|
216
250
|
*/
|
|
217
|
-
todo?: string;
|
|
251
|
+
todo?: string | boolean;
|
|
218
252
|
|
|
219
253
|
/**
|
|
220
254
|
* Present if `context.skip` is called.
|
|
221
255
|
*/
|
|
222
|
-
skip?: string;
|
|
256
|
+
skip?: string | boolean;
|
|
223
257
|
}
|
|
224
258
|
|
|
225
259
|
interface TestPass {
|
|
226
260
|
/**
|
|
227
|
-
*
|
|
261
|
+
* Additional execution metadata.
|
|
228
262
|
*/
|
|
229
|
-
|
|
263
|
+
details: {
|
|
264
|
+
/**
|
|
265
|
+
* The duration of the test in milliseconds.
|
|
266
|
+
*/
|
|
267
|
+
duration: number;
|
|
268
|
+
};
|
|
230
269
|
|
|
231
270
|
/**
|
|
232
271
|
* The test name.
|
|
233
272
|
*/
|
|
234
273
|
name: string;
|
|
235
274
|
|
|
275
|
+
/**
|
|
276
|
+
* The nesting level of the test.
|
|
277
|
+
*/
|
|
278
|
+
nesting: number;
|
|
279
|
+
|
|
236
280
|
/**
|
|
237
281
|
* The ordinal number of the test.
|
|
238
282
|
*/
|
|
@@ -241,12 +285,36 @@ declare module 'node:test' {
|
|
|
241
285
|
/**
|
|
242
286
|
* Present if `context.todo` is called.
|
|
243
287
|
*/
|
|
244
|
-
todo?: string;
|
|
288
|
+
todo?: string | boolean;
|
|
245
289
|
|
|
246
290
|
/**
|
|
247
291
|
* Present if `context.skip` is called.
|
|
248
292
|
*/
|
|
249
|
-
skip?: string;
|
|
293
|
+
skip?: string | boolean;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
interface TestPlan {
|
|
297
|
+
/**
|
|
298
|
+
* The nesting level of the test.
|
|
299
|
+
*/
|
|
300
|
+
nesting: number;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* The number of subtests that have ran.
|
|
304
|
+
*/
|
|
305
|
+
count: number;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
interface TestStart {
|
|
309
|
+
/**
|
|
310
|
+
* The test name.
|
|
311
|
+
*/
|
|
312
|
+
name: string;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* The nesting level of the test.
|
|
316
|
+
*/
|
|
317
|
+
nesting: number;
|
|
250
318
|
}
|
|
251
319
|
|
|
252
320
|
/**
|
|
@@ -283,9 +351,9 @@ declare module 'node:test' {
|
|
|
283
351
|
afterEach: typeof afterEach;
|
|
284
352
|
|
|
285
353
|
/**
|
|
286
|
-
* This function is used to write
|
|
354
|
+
* This function is used to write diagnostics to the output. Any diagnostic information is
|
|
287
355
|
* included at the end of the test's results. This function does not return a value.
|
|
288
|
-
* @param message Message to be
|
|
356
|
+
* @param message Message to be reported.
|
|
289
357
|
* @since v18.0.0
|
|
290
358
|
*/
|
|
291
359
|
diagnostic(message: string): void;
|
|
@@ -313,18 +381,18 @@ declare module 'node:test' {
|
|
|
313
381
|
|
|
314
382
|
/**
|
|
315
383
|
* This function causes the test's output to indicate the test as skipped. If `message` is
|
|
316
|
-
* provided, it is included in the
|
|
384
|
+
* provided, it is included in the output. Calling `skip()` does not terminate execution of
|
|
317
385
|
* the test function. This function does not return a value.
|
|
318
|
-
* @param message Optional skip message
|
|
386
|
+
* @param message Optional skip message.
|
|
319
387
|
* @since v18.0.0
|
|
320
388
|
*/
|
|
321
389
|
skip(message?: string): void;
|
|
322
390
|
|
|
323
391
|
/**
|
|
324
392
|
* This function adds a `TODO` directive to the test's output. If `message` is provided, it is
|
|
325
|
-
* included in the
|
|
393
|
+
* included in the output. Calling `todo()` does not terminate execution of the test
|
|
326
394
|
* function. This function does not return a value.
|
|
327
|
-
* @param message Optional `TODO` message
|
|
395
|
+
* @param message Optional `TODO` message.
|
|
328
396
|
* @since v18.0.0
|
|
329
397
|
*/
|
|
330
398
|
todo(message?: string): void;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* should generally include the module name to avoid collisions with data from
|
|
21
21
|
* other modules.
|
|
22
22
|
* @experimental
|
|
23
|
-
* @see [source](https://github.com/nodejs/node/blob/v18.
|
|
23
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.7.0/lib/diagnostics_channel.js)
|
|
24
24
|
*/
|
|
25
25
|
declare module 'diagnostics_channel' {
|
|
26
26
|
/**
|
|
@@ -58,6 +58,45 @@ declare module 'diagnostics_channel' {
|
|
|
58
58
|
*/
|
|
59
59
|
function channel(name: string | symbol): Channel;
|
|
60
60
|
type ChannelListener = (message: unknown, name: string | symbol) => void;
|
|
61
|
+
/**
|
|
62
|
+
* Register a message handler to subscribe to this channel. This message handler will be run synchronously
|
|
63
|
+
* whenever a message is published to the channel. Any errors thrown in the message handler will
|
|
64
|
+
* trigger an 'uncaughtException'.
|
|
65
|
+
*
|
|
66
|
+
* ```js
|
|
67
|
+
* import diagnostics_channel from 'diagnostics_channel';
|
|
68
|
+
*
|
|
69
|
+
* diagnostics_channel.subscribe('my-channel', (message, name) => {
|
|
70
|
+
* // Received data
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @since v18.7.0, v16.17.0
|
|
75
|
+
* @param name The channel name
|
|
76
|
+
* @param onMessage The handler to receive channel messages
|
|
77
|
+
*/
|
|
78
|
+
function subscribe(name: string | symbol, onMessage: ChannelListener): void;
|
|
79
|
+
/**
|
|
80
|
+
* Remove a message handler previously registered to this channel with diagnostics_channel.subscribe(name, onMessage).
|
|
81
|
+
*
|
|
82
|
+
* ```js
|
|
83
|
+
* import diagnostics_channel from 'diagnostics_channel';
|
|
84
|
+
*
|
|
85
|
+
* function onMessage(message, name) {
|
|
86
|
+
* // Received data
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* diagnostics_channel.subscribe('my-channel', onMessage);
|
|
90
|
+
*
|
|
91
|
+
* diagnostics_channel.unsubscribe('my-channel', onMessage);
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @since v18.7.0, v16.17.0
|
|
95
|
+
* @param name The channel name
|
|
96
|
+
* @param onMessage The previous subscribed handler to remove
|
|
97
|
+
* @returns `true` if the handler was found, `false` otherwise
|
|
98
|
+
*/
|
|
99
|
+
function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean;
|
|
61
100
|
/**
|
|
62
101
|
* The class `Channel` represents an individual named channel within the data
|
|
63
102
|
* pipeline. It is use to track subscribers and to publish messages when there
|
node/ts4.8/dns.d.ts
CHANGED
node/ts4.8/http2.d.ts
CHANGED
|
@@ -1053,7 +1053,6 @@ declare module 'http2' {
|
|
|
1053
1053
|
*/
|
|
1054
1054
|
unknownProtocolTimeout?: number | undefined;
|
|
1055
1055
|
selectPadding?(frameLen: number, maxFrameLen: number): number;
|
|
1056
|
-
createConnection?(authority: url.URL, option: SessionOptions): stream.Duplex;
|
|
1057
1056
|
}
|
|
1058
1057
|
export interface ClientSessionOptions extends SessionOptions {
|
|
1059
1058
|
maxReservedRemoteStreams?: number | undefined;
|
node/ts4.8/process.d.ts
CHANGED
|
@@ -1089,6 +1089,12 @@ declare module 'process' {
|
|
|
1089
1089
|
*/
|
|
1090
1090
|
mainModule?: Module | undefined;
|
|
1091
1091
|
memoryUsage: MemoryUsageFn;
|
|
1092
|
+
/**
|
|
1093
|
+
* Gets the amount of memory available to the process (in bytes) based on
|
|
1094
|
+
* limits imposed by the OS. If there is no such constraint, or the constraint
|
|
1095
|
+
* is unknown, `undefined` is returned.
|
|
1096
|
+
*/
|
|
1097
|
+
constrainedMemory(): number | undefined;
|
|
1092
1098
|
/**
|
|
1093
1099
|
* The `process.cpuUsage()` method returns the user and system CPU time usage of
|
|
1094
1100
|
* the current process, in an object with properties `user` and `system`, whose
|
node/ts4.8/test.d.ts
CHANGED
|
@@ -7,16 +7,16 @@ declare module 'node:test' {
|
|
|
7
7
|
* Programmatically start the test runner.
|
|
8
8
|
* @since v18.9.0
|
|
9
9
|
* @param options Configuration options for running tests.
|
|
10
|
-
* @returns A {@link
|
|
10
|
+
* @returns A {@link TestsStream} that emits events about the test execution.
|
|
11
11
|
*/
|
|
12
|
-
function run(options?: RunOptions):
|
|
12
|
+
function run(options?: RunOptions): TestsStream;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The `test()` function is the value imported from the test module. Each invocation of this
|
|
16
|
-
* function results in the
|
|
16
|
+
* function results in reporting the test to the {@link TestsStream}.
|
|
17
17
|
*
|
|
18
18
|
* The {@link TestContext} object passed to the fn argument can be used to perform actions
|
|
19
|
-
* related to the current test. Examples include skipping the test, adding additional
|
|
19
|
+
* related to the current test. Examples include skipping the test, adding additional
|
|
20
20
|
* diagnostic information, or creating subtests.
|
|
21
21
|
*
|
|
22
22
|
* `test()` returns a {@link Promise} that resolves once the test completes. The return value
|
|
@@ -158,54 +158,88 @@ declare module 'node:test' {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
* A successful call of the `run()` method will return a new `
|
|
162
|
-
* streaming a
|
|
163
|
-
* `
|
|
161
|
+
* A successful call of the `run()` method will return a new `TestsStream` object,
|
|
162
|
+
* streaming a series of events representing the execution of the tests.
|
|
163
|
+
* `TestsStream` will emit events in the order of the tests' definitions.
|
|
164
164
|
* @since v18.9.0
|
|
165
165
|
*/
|
|
166
|
-
interface
|
|
167
|
-
addListener(event: 'test:diagnostic', listener: (
|
|
166
|
+
interface TestsStream extends NodeJS.ReadableStream {
|
|
167
|
+
addListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
|
|
168
168
|
addListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
169
169
|
addListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
170
|
+
addListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
|
|
171
|
+
addListener(event: 'test:start', listener: (data: TestStart) => void): this;
|
|
170
172
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
171
|
-
emit(event: 'test:diagnostic',
|
|
173
|
+
emit(event: 'test:diagnostic', data: DiagnosticData): boolean;
|
|
172
174
|
emit(event: 'test:fail', data: TestFail): boolean;
|
|
173
175
|
emit(event: 'test:pass', data: TestPass): boolean;
|
|
176
|
+
emit(event: 'test:plan', data: TestPlan): boolean;
|
|
177
|
+
emit(event: 'test:start', data: TestStart): boolean;
|
|
174
178
|
emit(event: string | symbol, ...args: any[]): boolean;
|
|
175
|
-
on(event: 'test:diagnostic', listener: (
|
|
179
|
+
on(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
|
|
176
180
|
on(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
177
181
|
on(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
182
|
+
on(event: 'test:plan', listener: (data: TestPlan) => void): this;
|
|
183
|
+
on(event: 'test:start', listener: (data: TestStart) => void): this;
|
|
178
184
|
on(event: string, listener: (...args: any[]) => void): this;
|
|
179
|
-
once(event: 'test:diagnostic', listener: (
|
|
185
|
+
once(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
|
|
180
186
|
once(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
181
187
|
once(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
188
|
+
once(event: 'test:plan', listener: (data: TestPlan) => void): this;
|
|
189
|
+
once(event: 'test:start', listener: (data: TestStart) => void): this;
|
|
182
190
|
once(event: string, listener: (...args: any[]) => void): this;
|
|
183
|
-
prependListener(event: 'test:diagnostic', listener: (
|
|
191
|
+
prependListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
|
|
184
192
|
prependListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
185
193
|
prependListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
194
|
+
prependListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
|
|
195
|
+
prependListener(event: 'test:start', listener: (data: TestStart) => void): this;
|
|
186
196
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
187
|
-
prependOnceListener(event: 'test:diagnostic', listener: (
|
|
197
|
+
prependOnceListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
|
|
188
198
|
prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
189
199
|
prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
200
|
+
prependOnceListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
|
|
201
|
+
prependOnceListener(event: 'test:start', listener: (data: TestStart) => void): this;
|
|
190
202
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
191
203
|
}
|
|
192
204
|
|
|
193
|
-
interface
|
|
205
|
+
interface DiagnosticData {
|
|
206
|
+
/**
|
|
207
|
+
* The diagnostic message.
|
|
208
|
+
*/
|
|
209
|
+
message: string;
|
|
210
|
+
|
|
194
211
|
/**
|
|
195
|
-
* The test
|
|
212
|
+
* The nesting level of the test.
|
|
196
213
|
*/
|
|
197
|
-
|
|
214
|
+
nesting: number;
|
|
215
|
+
}
|
|
198
216
|
|
|
217
|
+
interface TestFail {
|
|
199
218
|
/**
|
|
200
|
-
*
|
|
219
|
+
* Additional execution metadata.
|
|
201
220
|
*/
|
|
202
|
-
|
|
221
|
+
details: {
|
|
222
|
+
/**
|
|
223
|
+
* The duration of the test in milliseconds.
|
|
224
|
+
*/
|
|
225
|
+
duration: number;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The error thrown by the test.
|
|
229
|
+
*/
|
|
230
|
+
error: Error;
|
|
231
|
+
};
|
|
203
232
|
|
|
204
233
|
/**
|
|
205
234
|
* The test name.
|
|
206
235
|
*/
|
|
207
236
|
name: string;
|
|
208
237
|
|
|
238
|
+
/**
|
|
239
|
+
* The nesting level of the test.
|
|
240
|
+
*/
|
|
241
|
+
nesting: number;
|
|
242
|
+
|
|
209
243
|
/**
|
|
210
244
|
* The ordinal number of the test.
|
|
211
245
|
*/
|
|
@@ -214,25 +248,35 @@ declare module 'node:test' {
|
|
|
214
248
|
/**
|
|
215
249
|
* Present if `context.todo` is called.
|
|
216
250
|
*/
|
|
217
|
-
todo?: string;
|
|
251
|
+
todo?: string | boolean;
|
|
218
252
|
|
|
219
253
|
/**
|
|
220
254
|
* Present if `context.skip` is called.
|
|
221
255
|
*/
|
|
222
|
-
skip?: string;
|
|
256
|
+
skip?: string | boolean;
|
|
223
257
|
}
|
|
224
258
|
|
|
225
259
|
interface TestPass {
|
|
226
260
|
/**
|
|
227
|
-
*
|
|
261
|
+
* Additional execution metadata.
|
|
228
262
|
*/
|
|
229
|
-
|
|
263
|
+
details: {
|
|
264
|
+
/**
|
|
265
|
+
* The duration of the test in milliseconds.
|
|
266
|
+
*/
|
|
267
|
+
duration: number;
|
|
268
|
+
};
|
|
230
269
|
|
|
231
270
|
/**
|
|
232
271
|
* The test name.
|
|
233
272
|
*/
|
|
234
273
|
name: string;
|
|
235
274
|
|
|
275
|
+
/**
|
|
276
|
+
* The nesting level of the test.
|
|
277
|
+
*/
|
|
278
|
+
nesting: number;
|
|
279
|
+
|
|
236
280
|
/**
|
|
237
281
|
* The ordinal number of the test.
|
|
238
282
|
*/
|
|
@@ -241,12 +285,36 @@ declare module 'node:test' {
|
|
|
241
285
|
/**
|
|
242
286
|
* Present if `context.todo` is called.
|
|
243
287
|
*/
|
|
244
|
-
todo?: string;
|
|
288
|
+
todo?: string | boolean;
|
|
245
289
|
|
|
246
290
|
/**
|
|
247
291
|
* Present if `context.skip` is called.
|
|
248
292
|
*/
|
|
249
|
-
skip?: string;
|
|
293
|
+
skip?: string | boolean;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
interface TestPlan {
|
|
297
|
+
/**
|
|
298
|
+
* The nesting level of the test.
|
|
299
|
+
*/
|
|
300
|
+
nesting: number;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* The number of subtests that have ran.
|
|
304
|
+
*/
|
|
305
|
+
count: number;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
interface TestStart {
|
|
309
|
+
/**
|
|
310
|
+
* The test name.
|
|
311
|
+
*/
|
|
312
|
+
name: string;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* The nesting level of the test.
|
|
316
|
+
*/
|
|
317
|
+
nesting: number;
|
|
250
318
|
}
|
|
251
319
|
|
|
252
320
|
/**
|
|
@@ -283,9 +351,9 @@ declare module 'node:test' {
|
|
|
283
351
|
afterEach: typeof afterEach;
|
|
284
352
|
|
|
285
353
|
/**
|
|
286
|
-
* This function is used to write
|
|
354
|
+
* This function is used to write diagnostics to the output. Any diagnostic information is
|
|
287
355
|
* included at the end of the test's results. This function does not return a value.
|
|
288
|
-
* @param message Message to be
|
|
356
|
+
* @param message Message to be reported.
|
|
289
357
|
* @since v18.0.0
|
|
290
358
|
*/
|
|
291
359
|
diagnostic(message: string): void;
|
|
@@ -313,18 +381,18 @@ declare module 'node:test' {
|
|
|
313
381
|
|
|
314
382
|
/**
|
|
315
383
|
* This function causes the test's output to indicate the test as skipped. If `message` is
|
|
316
|
-
* provided, it is included in the
|
|
384
|
+
* provided, it is included in the output. Calling `skip()` does not terminate execution of
|
|
317
385
|
* the test function. This function does not return a value.
|
|
318
|
-
* @param message Optional skip message
|
|
386
|
+
* @param message Optional skip message.
|
|
319
387
|
* @since v18.0.0
|
|
320
388
|
*/
|
|
321
389
|
skip(message?: string): void;
|
|
322
390
|
|
|
323
391
|
/**
|
|
324
392
|
* This function adds a `TODO` directive to the test's output. If `message` is provided, it is
|
|
325
|
-
* included in the
|
|
393
|
+
* included in the output. Calling `todo()` does not terminate execution of the test
|
|
326
394
|
* function. This function does not return a value.
|
|
327
|
-
* @param message Optional `TODO` message
|
|
395
|
+
* @param message Optional `TODO` message.
|
|
328
396
|
* @since v18.0.0
|
|
329
397
|
*/
|
|
330
398
|
todo(message?: string): void;
|
node/ts4.8/v8.d.ts
CHANGED
|
@@ -390,6 +390,57 @@ declare module 'v8' {
|
|
|
390
390
|
* @since v15.1.0, v14.18.0, v12.22.0
|
|
391
391
|
*/
|
|
392
392
|
function stopCoverage(): void;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* This API collects GC data in current thread.
|
|
396
|
+
*/
|
|
397
|
+
class GCProfiler {
|
|
398
|
+
/**
|
|
399
|
+
* Start collecting GC data.
|
|
400
|
+
*/
|
|
401
|
+
start(): void;
|
|
402
|
+
/**
|
|
403
|
+
* Stop collecting GC data and return a object.
|
|
404
|
+
*/
|
|
405
|
+
stop(): GCProfilerResult;
|
|
406
|
+
}
|
|
407
|
+
interface GCProfilerResult {
|
|
408
|
+
version: number;
|
|
409
|
+
startTime: number;
|
|
410
|
+
endTime: number;
|
|
411
|
+
statistics: Array<{
|
|
412
|
+
gcType: string;
|
|
413
|
+
cost: number;
|
|
414
|
+
beforeGC: {
|
|
415
|
+
heapStatistics: HeapStatistics;
|
|
416
|
+
heapSpaceStatistics: HeapSpaceStatistics[];
|
|
417
|
+
};
|
|
418
|
+
afterGC: {
|
|
419
|
+
heapStatistics: HeapStatistics;
|
|
420
|
+
heapSpaceStatistics: HeapSpaceStatistics[];
|
|
421
|
+
};
|
|
422
|
+
}>;
|
|
423
|
+
}
|
|
424
|
+
interface HeapStatistics {
|
|
425
|
+
totalHeapSize: number;
|
|
426
|
+
totalHeapSizeExecutable: number;
|
|
427
|
+
totalPhysicalSize: number;
|
|
428
|
+
totalAvailableSize: number;
|
|
429
|
+
totalGlobalHandlesSize: number;
|
|
430
|
+
usedGlobalHandlesSize: number;
|
|
431
|
+
usedHeapSize: number;
|
|
432
|
+
heapSizeLimit: number;
|
|
433
|
+
mallocedMemory: number;
|
|
434
|
+
externalMemory: number;
|
|
435
|
+
peakMallocedMemory: number;
|
|
436
|
+
}
|
|
437
|
+
interface HeapSpaceStatistics {
|
|
438
|
+
spaceName: string;
|
|
439
|
+
spaceSize: number;
|
|
440
|
+
spaceUsedSize: number;
|
|
441
|
+
spaceAvailableSize: number;
|
|
442
|
+
physicalSpaceSize: number;
|
|
443
|
+
}
|
|
393
444
|
}
|
|
394
445
|
declare module 'node:v8' {
|
|
395
446
|
export * from 'v8';
|
node/ts4.8/vm.d.ts
CHANGED
|
@@ -56,11 +56,17 @@ declare module 'vm' {
|
|
|
56
56
|
columnOffset?: number | undefined;
|
|
57
57
|
}
|
|
58
58
|
interface ScriptOptions extends BaseOptions {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
/**
|
|
60
|
+
* V8's code cache data for the supplied source.
|
|
61
|
+
*/
|
|
62
|
+
cachedData?: Buffer | NodeJS.ArrayBufferView | undefined;
|
|
62
63
|
/** @deprecated in favor of `script.createCachedData()` */
|
|
63
64
|
produceCachedData?: boolean | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Called during evaluation of this module when `import()` is called.
|
|
67
|
+
* If this option is not specified, calls to `import()` will reject with `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`.
|
|
68
|
+
*/
|
|
69
|
+
importModuleDynamically?: ((specifier: string, script: Script, importAssertions: Object) => Module) | undefined;
|
|
64
70
|
}
|
|
65
71
|
interface RunningScriptOptions extends BaseOptions {
|
|
66
72
|
/**
|
|
@@ -80,10 +86,31 @@ declare module 'vm' {
|
|
|
80
86
|
* Default: `false`.
|
|
81
87
|
*/
|
|
82
88
|
breakOnSigint?: boolean | undefined;
|
|
89
|
+
}
|
|
90
|
+
interface RunningScriptInNewContextOptions extends RunningScriptOptions {
|
|
91
|
+
/**
|
|
92
|
+
* Human-readable name of the newly created context.
|
|
93
|
+
*/
|
|
94
|
+
contextName?: CreateContextOptions['name'];
|
|
95
|
+
/**
|
|
96
|
+
* Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL,
|
|
97
|
+
* but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object.
|
|
98
|
+
* Most notably, this string should omit the trailing slash, as that denotes a path.
|
|
99
|
+
*/
|
|
100
|
+
contextOrigin?: CreateContextOptions['origin'];
|
|
101
|
+
contextCodeGeneration?: CreateContextOptions['codeGeneration'];
|
|
83
102
|
/**
|
|
84
103
|
* If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
|
|
85
104
|
*/
|
|
86
|
-
microtaskMode?: '
|
|
105
|
+
microtaskMode?: CreateContextOptions['microtaskMode'];
|
|
106
|
+
}
|
|
107
|
+
interface RunningCodeOptions extends RunningScriptOptions {
|
|
108
|
+
cachedData?: ScriptOptions['cachedData'];
|
|
109
|
+
importModuleDynamically?: ScriptOptions['importModuleDynamically'];
|
|
110
|
+
}
|
|
111
|
+
interface RunningCodeInNewContextOptions extends RunningScriptInNewContextOptions {
|
|
112
|
+
cachedData?: ScriptOptions['cachedData'];
|
|
113
|
+
importModuleDynamically?: ScriptOptions['importModuleDynamically'];
|
|
87
114
|
}
|
|
88
115
|
interface CompileFunctionOptions extends BaseOptions {
|
|
89
116
|
/**
|
|
@@ -144,7 +171,10 @@ declare module 'vm' {
|
|
|
144
171
|
* @default 'summary'
|
|
145
172
|
*/
|
|
146
173
|
mode?: MeasureMemoryMode | undefined;
|
|
147
|
-
|
|
174
|
+
/**
|
|
175
|
+
* @default 'default'
|
|
176
|
+
*/
|
|
177
|
+
execution?: 'default' | 'eager' | undefined;
|
|
148
178
|
}
|
|
149
179
|
interface MemoryMeasurement {
|
|
150
180
|
total: {
|
|
@@ -158,7 +188,7 @@ declare module 'vm' {
|
|
|
158
188
|
* @since v0.3.1
|
|
159
189
|
*/
|
|
160
190
|
class Script {
|
|
161
|
-
constructor(code: string, options?: ScriptOptions);
|
|
191
|
+
constructor(code: string, options?: ScriptOptions | string);
|
|
162
192
|
/**
|
|
163
193
|
* Runs the compiled code contained by the `vm.Script` object within the given`contextifiedObject` and returns the result. Running code does not have access
|
|
164
194
|
* to local scope.
|
|
@@ -220,7 +250,7 @@ declare module 'vm' {
|
|
|
220
250
|
* @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
|
|
221
251
|
* @return the result of the very last statement executed in the script.
|
|
222
252
|
*/
|
|
223
|
-
runInNewContext(contextObject?: Context, options?:
|
|
253
|
+
runInNewContext(contextObject?: Context, options?: RunningScriptInNewContextOptions): any;
|
|
224
254
|
/**
|
|
225
255
|
* Runs the compiled code contained by the `vm.Script` within the context of the
|
|
226
256
|
* current `global` object. Running code does not have access to local scope, but _does_ have access to the current `global` object.
|
|
@@ -273,6 +303,10 @@ declare module 'vm' {
|
|
|
273
303
|
cachedDataProduced?: boolean | undefined;
|
|
274
304
|
cachedDataRejected?: boolean | undefined;
|
|
275
305
|
cachedData?: Buffer | undefined;
|
|
306
|
+
/**
|
|
307
|
+
* When the script is compiled from a source that contains a source map magic comment, this property will be set to the URL of the source map.
|
|
308
|
+
*/
|
|
309
|
+
sourceMapURL?: string | undefined;
|
|
276
310
|
}
|
|
277
311
|
/**
|
|
278
312
|
* If given a `contextObject`, the `vm.createContext()` method will `prepare
|
|
@@ -345,7 +379,7 @@ declare module 'vm' {
|
|
|
345
379
|
* @param contextifiedObject The `contextified` object that will be used as the `global` when the `code` is compiled and run.
|
|
346
380
|
* @return the result of the very last statement executed in the script.
|
|
347
381
|
*/
|
|
348
|
-
function runInContext(code: string, contextifiedObject: Context, options?:
|
|
382
|
+
function runInContext(code: string, contextifiedObject: Context, options?: RunningCodeOptions | string): any;
|
|
349
383
|
/**
|
|
350
384
|
* The `vm.runInNewContext()` first contextifies the given `contextObject` (or
|
|
351
385
|
* creates a new `contextObject` if passed as `undefined`), compiles the `code`,
|
|
@@ -374,7 +408,7 @@ declare module 'vm' {
|
|
|
374
408
|
* @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
|
|
375
409
|
* @return the result of the very last statement executed in the script.
|
|
376
410
|
*/
|
|
377
|
-
function runInNewContext(code: string, contextObject?: Context, options?:
|
|
411
|
+
function runInNewContext(code: string, contextObject?: Context, options?: RunningCodeInNewContextOptions | string): any;
|
|
378
412
|
/**
|
|
379
413
|
* `vm.runInThisContext()` compiles `code`, runs it within the context of the
|
|
380
414
|
* current `global` and returns the result. Running code does not have access to
|
|
@@ -437,7 +471,7 @@ declare module 'vm' {
|
|
|
437
471
|
* @param code The JavaScript code to compile and run.
|
|
438
472
|
* @return the result of the very last statement executed in the script.
|
|
439
473
|
*/
|
|
440
|
-
function runInThisContext(code: string, options?:
|
|
474
|
+
function runInThisContext(code: string, options?: RunningCodeOptions | string): any;
|
|
441
475
|
/**
|
|
442
476
|
* Compiles the given code into the provided context (if no context is
|
|
443
477
|
* supplied, the current context is used), and returns it wrapped inside a
|
|
@@ -446,7 +480,11 @@ declare module 'vm' {
|
|
|
446
480
|
* @param code The body of the function to compile.
|
|
447
481
|
* @param params An array of strings containing all parameters for the function.
|
|
448
482
|
*/
|
|
449
|
-
function compileFunction(code: string, params?: ReadonlyArray<string>, options?: CompileFunctionOptions): Function
|
|
483
|
+
function compileFunction(code: string, params?: ReadonlyArray<string>, options?: CompileFunctionOptions): Function & {
|
|
484
|
+
cachedData?: Script['cachedData'] | undefined;
|
|
485
|
+
cachedDataProduced?: Script['cachedDataProduced'] | undefined;
|
|
486
|
+
cachedDataRejected?: Script['cachedDataRejected'] | undefined;
|
|
487
|
+
};
|
|
450
488
|
/**
|
|
451
489
|
* Measure the memory known to V8 and used by all contexts known to the
|
|
452
490
|
* current V8 isolate, or the main context.
|
|
@@ -503,6 +541,103 @@ declare module 'vm' {
|
|
|
503
541
|
* @experimental
|
|
504
542
|
*/
|
|
505
543
|
function measureMemory(options?: MeasureMemoryOptions): Promise<MemoryMeasurement>;
|
|
544
|
+
|
|
545
|
+
interface ModuleEvaluateOptions {
|
|
546
|
+
timeout?: RunningScriptOptions['timeout'] | undefined;
|
|
547
|
+
breakOnSigint?: RunningScriptOptions['breakOnSigint'] | undefined;
|
|
548
|
+
}
|
|
549
|
+
type ModuleLinker = (specifier: string, referencingModule: Module, extra: { assert: Object }) => Module | Promise<Module>;
|
|
550
|
+
type ModuleStatus = 'unlinked' | 'linking' | 'linked' | 'evaluating' | 'evaluated' | 'errored';
|
|
551
|
+
class Module {
|
|
552
|
+
/**
|
|
553
|
+
* The specifiers of all dependencies of this module.
|
|
554
|
+
*/
|
|
555
|
+
dependencySpecifiers: readonly string[];
|
|
556
|
+
/**
|
|
557
|
+
* If the `module.status` is `'errored'`, this property contains the exception thrown by the module during evaluation.
|
|
558
|
+
* If the status is anything else, accessing this property will result in a thrown exception.
|
|
559
|
+
*/
|
|
560
|
+
error: any;
|
|
561
|
+
/**
|
|
562
|
+
* The identifier of the current module, as set in the constructor.
|
|
563
|
+
*/
|
|
564
|
+
identifier: string;
|
|
565
|
+
context: Context;
|
|
566
|
+
/**
|
|
567
|
+
* The namespace object of the module. This is only available after linking (`module.link()`) has completed.
|
|
568
|
+
*/
|
|
569
|
+
namespace: Object;
|
|
570
|
+
/**
|
|
571
|
+
* The current status of the module.
|
|
572
|
+
*/
|
|
573
|
+
status: ModuleStatus;
|
|
574
|
+
/**
|
|
575
|
+
* Evaluate the module.
|
|
576
|
+
*
|
|
577
|
+
* This must be called after the module has been linked; otherwise it will reject
|
|
578
|
+
* It could be called also when the module has already been evaluated, in which case it will either do nothing
|
|
579
|
+
* if the initial evaluation ended in success (`module.status` is `'evaluated'`) or it will re-throw the exception
|
|
580
|
+
* that the initial evaluation resulted in (`module.status` is `'errored'`).
|
|
581
|
+
*
|
|
582
|
+
* This method cannot be called while the module is being evaluated (`module.status` is `'evaluating'`).
|
|
583
|
+
*/
|
|
584
|
+
evaluate(options?: ModuleEvaluateOptions): Promise<void>;
|
|
585
|
+
/**
|
|
586
|
+
* Link module dependencies. This method must be called before evaluation, and can only be called once per module.
|
|
587
|
+
*/
|
|
588
|
+
link(linker: ModuleLinker): Promise<void>;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
interface SourceTextModuleOptions {
|
|
592
|
+
/**
|
|
593
|
+
* String used in stack traces.
|
|
594
|
+
* @default 'vm:module(i)' where i is a context-specific ascending index.
|
|
595
|
+
*/
|
|
596
|
+
identifier?: string | undefined;
|
|
597
|
+
cachedData?: ScriptOptions['cachedData'] | undefined;
|
|
598
|
+
context?: Context | undefined;
|
|
599
|
+
lineOffset?: BaseOptions['lineOffset'] | undefined;
|
|
600
|
+
columnOffset?: BaseOptions['columnOffset'] | undefined;
|
|
601
|
+
/**
|
|
602
|
+
* Called during evaluation of this module to initialize the `import.meta`.
|
|
603
|
+
*/
|
|
604
|
+
initializeImportMeta?: ((meta: ImportMeta, module: SourceTextModule) => void) | undefined;
|
|
605
|
+
importModuleDynamically?: ScriptOptions['importModuleDynamically'] | undefined;
|
|
606
|
+
}
|
|
607
|
+
class SourceTextModule extends Module {
|
|
608
|
+
/**
|
|
609
|
+
* Creates a new `SourceTextModule` instance.
|
|
610
|
+
* @param code JavaScript Module code to parse
|
|
611
|
+
*/
|
|
612
|
+
constructor(code: string, options?: SourceTextModuleOptions);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
interface SyntheticModuleOptions {
|
|
616
|
+
/**
|
|
617
|
+
* String used in stack traces.
|
|
618
|
+
* @default 'vm:module(i)' where i is a context-specific ascending index.
|
|
619
|
+
*/
|
|
620
|
+
identifier?: string | undefined;
|
|
621
|
+
/**
|
|
622
|
+
* The contextified object as returned by the `vm.createContext()` method, to compile and evaluate this module in.
|
|
623
|
+
*/
|
|
624
|
+
context?: Context | undefined;
|
|
625
|
+
}
|
|
626
|
+
class SyntheticModule extends Module {
|
|
627
|
+
/**
|
|
628
|
+
* Creates a new `SyntheticModule` instance.
|
|
629
|
+
* @param exportNames Array of names that will be exported from the module.
|
|
630
|
+
* @param evaluateCallback Called when the module is evaluated.
|
|
631
|
+
*/
|
|
632
|
+
constructor(exportNames: string[], evaluateCallback: (this: SyntheticModule) => void, options?: SyntheticModuleOptions);
|
|
633
|
+
/**
|
|
634
|
+
* This method is used after the module is linked to set the values of exports.
|
|
635
|
+
* If it is called before the module is linked, an `ERR_VM_MODULE_STATUS` error will be thrown.
|
|
636
|
+
* @param name
|
|
637
|
+
* @param value
|
|
638
|
+
*/
|
|
639
|
+
setExport(name: string, value: any): void;
|
|
640
|
+
}
|
|
506
641
|
}
|
|
507
642
|
declare module 'node:vm' {
|
|
508
643
|
export * from 'vm';
|
node/v8.d.ts
CHANGED
|
@@ -390,6 +390,57 @@ declare module 'v8' {
|
|
|
390
390
|
* @since v15.1.0, v14.18.0, v12.22.0
|
|
391
391
|
*/
|
|
392
392
|
function stopCoverage(): void;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* This API collects GC data in current thread.
|
|
396
|
+
*/
|
|
397
|
+
class GCProfiler {
|
|
398
|
+
/**
|
|
399
|
+
* Start collecting GC data.
|
|
400
|
+
*/
|
|
401
|
+
start(): void;
|
|
402
|
+
/**
|
|
403
|
+
* Stop collecting GC data and return a object.
|
|
404
|
+
*/
|
|
405
|
+
stop(): GCProfilerResult;
|
|
406
|
+
}
|
|
407
|
+
interface GCProfilerResult {
|
|
408
|
+
version: number;
|
|
409
|
+
startTime: number;
|
|
410
|
+
endTime: number;
|
|
411
|
+
statistics: Array<{
|
|
412
|
+
gcType: string;
|
|
413
|
+
cost: number;
|
|
414
|
+
beforeGC: {
|
|
415
|
+
heapStatistics: HeapStatistics;
|
|
416
|
+
heapSpaceStatistics: HeapSpaceStatistics[];
|
|
417
|
+
};
|
|
418
|
+
afterGC: {
|
|
419
|
+
heapStatistics: HeapStatistics;
|
|
420
|
+
heapSpaceStatistics: HeapSpaceStatistics[];
|
|
421
|
+
};
|
|
422
|
+
}>;
|
|
423
|
+
}
|
|
424
|
+
interface HeapStatistics {
|
|
425
|
+
totalHeapSize: number;
|
|
426
|
+
totalHeapSizeExecutable: number;
|
|
427
|
+
totalPhysicalSize: number;
|
|
428
|
+
totalAvailableSize: number;
|
|
429
|
+
totalGlobalHandlesSize: number;
|
|
430
|
+
usedGlobalHandlesSize: number;
|
|
431
|
+
usedHeapSize: number;
|
|
432
|
+
heapSizeLimit: number;
|
|
433
|
+
mallocedMemory: number;
|
|
434
|
+
externalMemory: number;
|
|
435
|
+
peakMallocedMemory: number;
|
|
436
|
+
}
|
|
437
|
+
interface HeapSpaceStatistics {
|
|
438
|
+
spaceName: string;
|
|
439
|
+
spaceSize: number;
|
|
440
|
+
spaceUsedSize: number;
|
|
441
|
+
spaceAvailableSize: number;
|
|
442
|
+
physicalSpaceSize: number;
|
|
443
|
+
}
|
|
393
444
|
}
|
|
394
445
|
declare module 'node:v8' {
|
|
395
446
|
export * from 'v8';
|
node/vm.d.ts
CHANGED
|
@@ -56,11 +56,17 @@ declare module 'vm' {
|
|
|
56
56
|
columnOffset?: number | undefined;
|
|
57
57
|
}
|
|
58
58
|
interface ScriptOptions extends BaseOptions {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
/**
|
|
60
|
+
* V8's code cache data for the supplied source.
|
|
61
|
+
*/
|
|
62
|
+
cachedData?: Buffer | NodeJS.ArrayBufferView | undefined;
|
|
62
63
|
/** @deprecated in favor of `script.createCachedData()` */
|
|
63
64
|
produceCachedData?: boolean | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Called during evaluation of this module when `import()` is called.
|
|
67
|
+
* If this option is not specified, calls to `import()` will reject with `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`.
|
|
68
|
+
*/
|
|
69
|
+
importModuleDynamically?: ((specifier: string, script: Script, importAssertions: Object) => Module) | undefined;
|
|
64
70
|
}
|
|
65
71
|
interface RunningScriptOptions extends BaseOptions {
|
|
66
72
|
/**
|
|
@@ -80,10 +86,31 @@ declare module 'vm' {
|
|
|
80
86
|
* Default: `false`.
|
|
81
87
|
*/
|
|
82
88
|
breakOnSigint?: boolean | undefined;
|
|
89
|
+
}
|
|
90
|
+
interface RunningScriptInNewContextOptions extends RunningScriptOptions {
|
|
91
|
+
/**
|
|
92
|
+
* Human-readable name of the newly created context.
|
|
93
|
+
*/
|
|
94
|
+
contextName?: CreateContextOptions['name'];
|
|
95
|
+
/**
|
|
96
|
+
* Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL,
|
|
97
|
+
* but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object.
|
|
98
|
+
* Most notably, this string should omit the trailing slash, as that denotes a path.
|
|
99
|
+
*/
|
|
100
|
+
contextOrigin?: CreateContextOptions['origin'];
|
|
101
|
+
contextCodeGeneration?: CreateContextOptions['codeGeneration'];
|
|
83
102
|
/**
|
|
84
103
|
* If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
|
|
85
104
|
*/
|
|
86
|
-
microtaskMode?: '
|
|
105
|
+
microtaskMode?: CreateContextOptions['microtaskMode'];
|
|
106
|
+
}
|
|
107
|
+
interface RunningCodeOptions extends RunningScriptOptions {
|
|
108
|
+
cachedData?: ScriptOptions['cachedData'];
|
|
109
|
+
importModuleDynamically?: ScriptOptions['importModuleDynamically'];
|
|
110
|
+
}
|
|
111
|
+
interface RunningCodeInNewContextOptions extends RunningScriptInNewContextOptions {
|
|
112
|
+
cachedData?: ScriptOptions['cachedData'];
|
|
113
|
+
importModuleDynamically?: ScriptOptions['importModuleDynamically'];
|
|
87
114
|
}
|
|
88
115
|
interface CompileFunctionOptions extends BaseOptions {
|
|
89
116
|
/**
|
|
@@ -144,7 +171,10 @@ declare module 'vm' {
|
|
|
144
171
|
* @default 'summary'
|
|
145
172
|
*/
|
|
146
173
|
mode?: MeasureMemoryMode | undefined;
|
|
147
|
-
|
|
174
|
+
/**
|
|
175
|
+
* @default 'default'
|
|
176
|
+
*/
|
|
177
|
+
execution?: 'default' | 'eager' | undefined;
|
|
148
178
|
}
|
|
149
179
|
interface MemoryMeasurement {
|
|
150
180
|
total: {
|
|
@@ -158,7 +188,7 @@ declare module 'vm' {
|
|
|
158
188
|
* @since v0.3.1
|
|
159
189
|
*/
|
|
160
190
|
class Script {
|
|
161
|
-
constructor(code: string, options?: ScriptOptions);
|
|
191
|
+
constructor(code: string, options?: ScriptOptions | string);
|
|
162
192
|
/**
|
|
163
193
|
* Runs the compiled code contained by the `vm.Script` object within the given`contextifiedObject` and returns the result. Running code does not have access
|
|
164
194
|
* to local scope.
|
|
@@ -220,7 +250,7 @@ declare module 'vm' {
|
|
|
220
250
|
* @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
|
|
221
251
|
* @return the result of the very last statement executed in the script.
|
|
222
252
|
*/
|
|
223
|
-
runInNewContext(contextObject?: Context, options?:
|
|
253
|
+
runInNewContext(contextObject?: Context, options?: RunningScriptInNewContextOptions): any;
|
|
224
254
|
/**
|
|
225
255
|
* Runs the compiled code contained by the `vm.Script` within the context of the
|
|
226
256
|
* current `global` object. Running code does not have access to local scope, but _does_ have access to the current `global` object.
|
|
@@ -273,6 +303,10 @@ declare module 'vm' {
|
|
|
273
303
|
cachedDataProduced?: boolean | undefined;
|
|
274
304
|
cachedDataRejected?: boolean | undefined;
|
|
275
305
|
cachedData?: Buffer | undefined;
|
|
306
|
+
/**
|
|
307
|
+
* When the script is compiled from a source that contains a source map magic comment, this property will be set to the URL of the source map.
|
|
308
|
+
*/
|
|
309
|
+
sourceMapURL?: string | undefined;
|
|
276
310
|
}
|
|
277
311
|
/**
|
|
278
312
|
* If given a `contextObject`, the `vm.createContext()` method will `prepare
|
|
@@ -345,7 +379,7 @@ declare module 'vm' {
|
|
|
345
379
|
* @param contextifiedObject The `contextified` object that will be used as the `global` when the `code` is compiled and run.
|
|
346
380
|
* @return the result of the very last statement executed in the script.
|
|
347
381
|
*/
|
|
348
|
-
function runInContext(code: string, contextifiedObject: Context, options?:
|
|
382
|
+
function runInContext(code: string, contextifiedObject: Context, options?: RunningCodeOptions | string): any;
|
|
349
383
|
/**
|
|
350
384
|
* The `vm.runInNewContext()` first contextifies the given `contextObject` (or
|
|
351
385
|
* creates a new `contextObject` if passed as `undefined`), compiles the `code`,
|
|
@@ -374,7 +408,7 @@ declare module 'vm' {
|
|
|
374
408
|
* @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
|
|
375
409
|
* @return the result of the very last statement executed in the script.
|
|
376
410
|
*/
|
|
377
|
-
function runInNewContext(code: string, contextObject?: Context, options?:
|
|
411
|
+
function runInNewContext(code: string, contextObject?: Context, options?: RunningCodeInNewContextOptions | string): any;
|
|
378
412
|
/**
|
|
379
413
|
* `vm.runInThisContext()` compiles `code`, runs it within the context of the
|
|
380
414
|
* current `global` and returns the result. Running code does not have access to
|
|
@@ -437,7 +471,7 @@ declare module 'vm' {
|
|
|
437
471
|
* @param code The JavaScript code to compile and run.
|
|
438
472
|
* @return the result of the very last statement executed in the script.
|
|
439
473
|
*/
|
|
440
|
-
function runInThisContext(code: string, options?:
|
|
474
|
+
function runInThisContext(code: string, options?: RunningCodeOptions | string): any;
|
|
441
475
|
/**
|
|
442
476
|
* Compiles the given code into the provided context (if no context is
|
|
443
477
|
* supplied, the current context is used), and returns it wrapped inside a
|
|
@@ -446,7 +480,11 @@ declare module 'vm' {
|
|
|
446
480
|
* @param code The body of the function to compile.
|
|
447
481
|
* @param params An array of strings containing all parameters for the function.
|
|
448
482
|
*/
|
|
449
|
-
function compileFunction(code: string, params?: ReadonlyArray<string>, options?: CompileFunctionOptions): Function
|
|
483
|
+
function compileFunction(code: string, params?: ReadonlyArray<string>, options?: CompileFunctionOptions): Function & {
|
|
484
|
+
cachedData?: Script['cachedData'] | undefined;
|
|
485
|
+
cachedDataProduced?: Script['cachedDataProduced'] | undefined;
|
|
486
|
+
cachedDataRejected?: Script['cachedDataRejected'] | undefined;
|
|
487
|
+
};
|
|
450
488
|
/**
|
|
451
489
|
* Measure the memory known to V8 and used by all contexts known to the
|
|
452
490
|
* current V8 isolate, or the main context.
|
|
@@ -503,6 +541,103 @@ declare module 'vm' {
|
|
|
503
541
|
* @experimental
|
|
504
542
|
*/
|
|
505
543
|
function measureMemory(options?: MeasureMemoryOptions): Promise<MemoryMeasurement>;
|
|
544
|
+
|
|
545
|
+
interface ModuleEvaluateOptions {
|
|
546
|
+
timeout?: RunningScriptOptions['timeout'] | undefined;
|
|
547
|
+
breakOnSigint?: RunningScriptOptions['breakOnSigint'] | undefined;
|
|
548
|
+
}
|
|
549
|
+
type ModuleLinker = (specifier: string, referencingModule: Module, extra: { assert: Object }) => Module | Promise<Module>;
|
|
550
|
+
type ModuleStatus = 'unlinked' | 'linking' | 'linked' | 'evaluating' | 'evaluated' | 'errored';
|
|
551
|
+
class Module {
|
|
552
|
+
/**
|
|
553
|
+
* The specifiers of all dependencies of this module.
|
|
554
|
+
*/
|
|
555
|
+
dependencySpecifiers: readonly string[];
|
|
556
|
+
/**
|
|
557
|
+
* If the `module.status` is `'errored'`, this property contains the exception thrown by the module during evaluation.
|
|
558
|
+
* If the status is anything else, accessing this property will result in a thrown exception.
|
|
559
|
+
*/
|
|
560
|
+
error: any;
|
|
561
|
+
/**
|
|
562
|
+
* The identifier of the current module, as set in the constructor.
|
|
563
|
+
*/
|
|
564
|
+
identifier: string;
|
|
565
|
+
context: Context;
|
|
566
|
+
/**
|
|
567
|
+
* The namespace object of the module. This is only available after linking (`module.link()`) has completed.
|
|
568
|
+
*/
|
|
569
|
+
namespace: Object;
|
|
570
|
+
/**
|
|
571
|
+
* The current status of the module.
|
|
572
|
+
*/
|
|
573
|
+
status: ModuleStatus;
|
|
574
|
+
/**
|
|
575
|
+
* Evaluate the module.
|
|
576
|
+
*
|
|
577
|
+
* This must be called after the module has been linked; otherwise it will reject
|
|
578
|
+
* It could be called also when the module has already been evaluated, in which case it will either do nothing
|
|
579
|
+
* if the initial evaluation ended in success (`module.status` is `'evaluated'`) or it will re-throw the exception
|
|
580
|
+
* that the initial evaluation resulted in (`module.status` is `'errored'`).
|
|
581
|
+
*
|
|
582
|
+
* This method cannot be called while the module is being evaluated (`module.status` is `'evaluating'`).
|
|
583
|
+
*/
|
|
584
|
+
evaluate(options?: ModuleEvaluateOptions): Promise<void>;
|
|
585
|
+
/**
|
|
586
|
+
* Link module dependencies. This method must be called before evaluation, and can only be called once per module.
|
|
587
|
+
*/
|
|
588
|
+
link(linker: ModuleLinker): Promise<void>;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
interface SourceTextModuleOptions {
|
|
592
|
+
/**
|
|
593
|
+
* String used in stack traces.
|
|
594
|
+
* @default 'vm:module(i)' where i is a context-specific ascending index.
|
|
595
|
+
*/
|
|
596
|
+
identifier?: string | undefined;
|
|
597
|
+
cachedData?: ScriptOptions['cachedData'] | undefined;
|
|
598
|
+
context?: Context | undefined;
|
|
599
|
+
lineOffset?: BaseOptions['lineOffset'] | undefined;
|
|
600
|
+
columnOffset?: BaseOptions['columnOffset'] | undefined;
|
|
601
|
+
/**
|
|
602
|
+
* Called during evaluation of this module to initialize the `import.meta`.
|
|
603
|
+
*/
|
|
604
|
+
initializeImportMeta?: ((meta: ImportMeta, module: SourceTextModule) => void) | undefined;
|
|
605
|
+
importModuleDynamically?: ScriptOptions['importModuleDynamically'] | undefined;
|
|
606
|
+
}
|
|
607
|
+
class SourceTextModule extends Module {
|
|
608
|
+
/**
|
|
609
|
+
* Creates a new `SourceTextModule` instance.
|
|
610
|
+
* @param code JavaScript Module code to parse
|
|
611
|
+
*/
|
|
612
|
+
constructor(code: string, options?: SourceTextModuleOptions);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
interface SyntheticModuleOptions {
|
|
616
|
+
/**
|
|
617
|
+
* String used in stack traces.
|
|
618
|
+
* @default 'vm:module(i)' where i is a context-specific ascending index.
|
|
619
|
+
*/
|
|
620
|
+
identifier?: string | undefined;
|
|
621
|
+
/**
|
|
622
|
+
* The contextified object as returned by the `vm.createContext()` method, to compile and evaluate this module in.
|
|
623
|
+
*/
|
|
624
|
+
context?: Context | undefined;
|
|
625
|
+
}
|
|
626
|
+
class SyntheticModule extends Module {
|
|
627
|
+
/**
|
|
628
|
+
* Creates a new `SyntheticModule` instance.
|
|
629
|
+
* @param exportNames Array of names that will be exported from the module.
|
|
630
|
+
* @param evaluateCallback Called when the module is evaluated.
|
|
631
|
+
*/
|
|
632
|
+
constructor(exportNames: string[], evaluateCallback: (this: SyntheticModule) => void, options?: SyntheticModuleOptions);
|
|
633
|
+
/**
|
|
634
|
+
* This method is used after the module is linked to set the values of exports.
|
|
635
|
+
* If it is called before the module is linked, an `ERR_VM_MODULE_STATUS` error will be thrown.
|
|
636
|
+
* @param name
|
|
637
|
+
* @param value
|
|
638
|
+
*/
|
|
639
|
+
setExport(name: string, value: any): void;
|
|
640
|
+
}
|
|
506
641
|
}
|
|
507
642
|
declare module 'node:vm' {
|
|
508
643
|
export * from 'vm';
|