@types/node 24.8.0 → 24.9.0
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/assert.d.ts +36 -1
- node/cluster.d.ts +1 -1
- node/crypto.d.ts +18 -6
- node/http.d.ts +11 -0
- node/package.json +3 -3
- node/sqlite.d.ts +108 -0
- node/util.d.ts +11 -2
- node/v8.d.ts +16 -0
- node/vm.d.ts +20 -0
- node/wasi.d.ts +1 -1
- node/worker_threads.d.ts +40 -3
node/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for node (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: Mon, 20 Oct 2025 15:34:50 GMT
|
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
|
13
13
|
|
|
14
14
|
# Credits
|
node/assert.d.ts
CHANGED
|
@@ -44,6 +44,13 @@ declare module "assert" {
|
|
|
44
44
|
* @default true
|
|
45
45
|
*/
|
|
46
46
|
strict?: boolean | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* If set to `true`, skips prototype and constructor
|
|
49
|
+
* comparison in deep equality checks.
|
|
50
|
+
* @since v24.9.0
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
skipPrototype?: boolean | undefined;
|
|
47
54
|
}
|
|
48
55
|
interface Assert extends Pick<typeof assert, AssertMethodNames> {
|
|
49
56
|
readonly [kOptions]: AssertOptions & { strict: false };
|
|
@@ -67,7 +74,8 @@ declare module "assert" {
|
|
|
67
74
|
* ```
|
|
68
75
|
*
|
|
69
76
|
* **Important**: When destructuring assertion methods from an `Assert` instance,
|
|
70
|
-
* the methods lose their connection to the instance's configuration options (such
|
|
77
|
+
* the methods lose their connection to the instance's configuration options (such
|
|
78
|
+
* as `diff`, `strict`, and `skipPrototype` settings).
|
|
71
79
|
* The destructured methods will fall back to default behavior instead.
|
|
72
80
|
*
|
|
73
81
|
* ```js
|
|
@@ -81,6 +89,33 @@ declare module "assert" {
|
|
|
81
89
|
* strictEqual({ a: 1 }, { b: { c: 1 } });
|
|
82
90
|
* ```
|
|
83
91
|
*
|
|
92
|
+
* The `skipPrototype` option affects all deep equality methods:
|
|
93
|
+
*
|
|
94
|
+
* ```js
|
|
95
|
+
* class Foo {
|
|
96
|
+
* constructor(a) {
|
|
97
|
+
* this.a = a;
|
|
98
|
+
* }
|
|
99
|
+
* }
|
|
100
|
+
*
|
|
101
|
+
* class Bar {
|
|
102
|
+
* constructor(a) {
|
|
103
|
+
* this.a = a;
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
*
|
|
107
|
+
* const foo = new Foo(1);
|
|
108
|
+
* const bar = new Bar(1);
|
|
109
|
+
*
|
|
110
|
+
* // Default behavior - fails due to different constructors
|
|
111
|
+
* const assert1 = new Assert();
|
|
112
|
+
* assert1.deepStrictEqual(foo, bar); // AssertionError
|
|
113
|
+
*
|
|
114
|
+
* // Skip prototype comparison - passes if properties are equal
|
|
115
|
+
* const assert2 = new Assert({ skipPrototype: true });
|
|
116
|
+
* assert2.deepStrictEqual(foo, bar); // OK
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
84
119
|
* When destructured, methods lose access to the instance's `this` context and revert to default assertion behavior
|
|
85
120
|
* (diff: 'simple', non-strict mode).
|
|
86
121
|
* To maintain custom options when using destructured methods, avoid
|
node/cluster.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ declare module "cluster" {
|
|
|
72
72
|
* String arguments passed to worker.
|
|
73
73
|
* @default process.argv.slice(2)
|
|
74
74
|
*/
|
|
75
|
-
args?: string[] | undefined;
|
|
75
|
+
args?: readonly string[] | undefined;
|
|
76
76
|
/**
|
|
77
77
|
* Whether or not to send output to parent's stdio.
|
|
78
78
|
* @default false
|
node/crypto.d.ts
CHANGED
|
@@ -4254,6 +4254,16 @@ declare module "crypto" {
|
|
|
4254
4254
|
* @since v15.6.0
|
|
4255
4255
|
*/
|
|
4256
4256
|
readonly serialNumber: string;
|
|
4257
|
+
/**
|
|
4258
|
+
* The algorithm used to sign the certificate or `undefined` if the signature algorithm is unknown by OpenSSL.
|
|
4259
|
+
* @since v24.9.0
|
|
4260
|
+
*/
|
|
4261
|
+
readonly signatureAlgorithm: string | undefined;
|
|
4262
|
+
/**
|
|
4263
|
+
* The OID of the algorithm used to sign the certificate.
|
|
4264
|
+
* @since v24.9.0
|
|
4265
|
+
*/
|
|
4266
|
+
readonly signatureAlgorithmOid: string;
|
|
4257
4267
|
/**
|
|
4258
4268
|
* The date/time from which this certificate is considered valid.
|
|
4259
4269
|
* @since v15.6.0
|
|
@@ -5138,9 +5148,9 @@ declare module "crypto" {
|
|
|
5138
5148
|
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
|
|
5139
5149
|
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
|
|
5140
5150
|
/**
|
|
5141
|
-
* Using the
|
|
5142
|
-
* attempts to generate new keying material. Depending the
|
|
5143
|
-
*
|
|
5151
|
+
* Using the parameters provided in `algorithm`, this method
|
|
5152
|
+
* attempts to generate new keying material. Depending on the algorithm used
|
|
5153
|
+
* either a single `CryptoKey` or a `CryptoKeyPair` is generated.
|
|
5144
5154
|
*
|
|
5145
5155
|
* The `CryptoKeyPair` (public and private key) generating algorithms supported
|
|
5146
5156
|
* include:
|
|
@@ -5198,9 +5208,11 @@ declare module "crypto" {
|
|
|
5198
5208
|
*/
|
|
5199
5209
|
getPublicKey(key: CryptoKey, keyUsages: KeyUsage[]): Promise<CryptoKey>;
|
|
5200
5210
|
/**
|
|
5201
|
-
*
|
|
5202
|
-
* to create a
|
|
5203
|
-
*
|
|
5211
|
+
* This method attempts to interpret the provided `keyData`
|
|
5212
|
+
* as the given `format` to create a `CryptoKey` instance using the provided
|
|
5213
|
+
* `algorithm`, `extractable`, and `keyUsages` arguments. If the import is
|
|
5214
|
+
* successful, the returned promise will be resolved with a {CryptoKey}
|
|
5215
|
+
* representation of the key material.
|
|
5204
5216
|
*
|
|
5205
5217
|
* If importing KDF algorithm keys, `extractable` must be `false`.
|
|
5206
5218
|
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`,
|
node/http.d.ts
CHANGED
|
@@ -339,6 +339,17 @@ declare module "http" {
|
|
|
339
339
|
* If the header's value is an array, the items will be joined using `; `.
|
|
340
340
|
*/
|
|
341
341
|
uniqueHeaders?: Array<string | string[]> | undefined;
|
|
342
|
+
/**
|
|
343
|
+
* A callback which receives an
|
|
344
|
+
* incoming request and returns a boolean, to control which upgrade attempts
|
|
345
|
+
* should be accepted. Accepted upgrades will fire an `'upgrade'` event (or
|
|
346
|
+
* their sockets will be destroyed, if no listener is registered) while
|
|
347
|
+
* rejected upgrades will fire a `'request'` event like any non-upgrade
|
|
348
|
+
* request.
|
|
349
|
+
* @since v24.9.0
|
|
350
|
+
* @default () => server.listenerCount('upgrade') > 0
|
|
351
|
+
*/
|
|
352
|
+
shouldUpgradeCallback?: ((request: InstanceType<Request>) => boolean) | undefined;
|
|
342
353
|
/**
|
|
343
354
|
* If set to `true`, an error is thrown when writing to an HTTP response which does not have a body.
|
|
344
355
|
* @default false
|
node/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.9.0",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -147,9 +147,9 @@
|
|
|
147
147
|
},
|
|
148
148
|
"scripts": {},
|
|
149
149
|
"dependencies": {
|
|
150
|
-
"undici-types": "~7.
|
|
150
|
+
"undici-types": "~7.16.0"
|
|
151
151
|
},
|
|
152
152
|
"peerDependencies": {},
|
|
153
|
-
"typesPublisherContentHash": "
|
|
153
|
+
"typesPublisherContentHash": "064e4fdcd32d717db146e9ad6c5cbc2d552244d1164550cba6cdf7dea564fb25",
|
|
154
154
|
"typeScriptVersion": "5.2"
|
|
155
155
|
}
|
node/sqlite.d.ts
CHANGED
|
@@ -355,6 +355,47 @@ declare module "node:sqlite" {
|
|
|
355
355
|
* @return The prepared statement.
|
|
356
356
|
*/
|
|
357
357
|
prepare(sql: string): StatementSync;
|
|
358
|
+
/**
|
|
359
|
+
* Creates a new `SQLTagStore`, which is an LRU (Least Recently Used) cache for
|
|
360
|
+
* storing prepared statements. This allows for the efficient reuse of prepared
|
|
361
|
+
* statements by tagging them with a unique identifier.
|
|
362
|
+
*
|
|
363
|
+
* When a tagged SQL literal is executed, the `SQLTagStore` checks if a prepared
|
|
364
|
+
* statement for that specific SQL string already exists in the cache. If it does,
|
|
365
|
+
* the cached statement is used. If not, a new prepared statement is created,
|
|
366
|
+
* executed, and then stored in the cache for future use. This mechanism helps to
|
|
367
|
+
* avoid the overhead of repeatedly parsing and preparing the same SQL statements.
|
|
368
|
+
*
|
|
369
|
+
* ```js
|
|
370
|
+
* import { DatabaseSync } from 'node:sqlite';
|
|
371
|
+
*
|
|
372
|
+
* const db = new DatabaseSync(':memory:');
|
|
373
|
+
* const sql = db.createSQLTagStore();
|
|
374
|
+
*
|
|
375
|
+
* db.exec('CREATE TABLE users (id INT, name TEXT)');
|
|
376
|
+
*
|
|
377
|
+
* // Using the 'run' method to insert data.
|
|
378
|
+
* // The tagged literal is used to identify the prepared statement.
|
|
379
|
+
* sql.run`INSERT INTO users VALUES (1, 'Alice')`;
|
|
380
|
+
* sql.run`INSERT INTO users VALUES (2, 'Bob')`;
|
|
381
|
+
*
|
|
382
|
+
* // Using the 'get' method to retrieve a single row.
|
|
383
|
+
* const id = 1;
|
|
384
|
+
* const user = sql.get`SELECT * FROM users WHERE id = ${id}`;
|
|
385
|
+
* console.log(user); // { id: 1, name: 'Alice' }
|
|
386
|
+
*
|
|
387
|
+
* // Using the 'all' method to retrieve all rows.
|
|
388
|
+
* const allUsers = sql.all`SELECT * FROM users ORDER BY id`;
|
|
389
|
+
* console.log(allUsers);
|
|
390
|
+
* // [
|
|
391
|
+
* // { id: 1, name: 'Alice' },
|
|
392
|
+
* // { id: 2, name: 'Bob' }
|
|
393
|
+
* // ]
|
|
394
|
+
* ```
|
|
395
|
+
* @since v24.9.0
|
|
396
|
+
* @returns A new SQL tag store for caching prepared statements.
|
|
397
|
+
*/
|
|
398
|
+
createTagStore(maxSize?: number): SQLTagStore;
|
|
358
399
|
/**
|
|
359
400
|
* Creates and attaches a session to the database. This method is a wrapper around
|
|
360
401
|
* [`sqlite3session_create()`](https://www.sqlite.org/session/sqlite3session_create.html) and
|
|
@@ -428,6 +469,73 @@ declare module "node:sqlite" {
|
|
|
428
469
|
*/
|
|
429
470
|
close(): void;
|
|
430
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* This class represents a single LRU (Least Recently Used) cache for storing
|
|
474
|
+
* prepared statements.
|
|
475
|
+
*
|
|
476
|
+
* Instances of this class are created via the database.createSQLTagStore() method,
|
|
477
|
+
* not by using a constructor. The store caches prepared statements based on the
|
|
478
|
+
* provided SQL query string. When the same query is seen again, the store
|
|
479
|
+
* retrieves the cached statement and safely applies the new values through
|
|
480
|
+
* parameter binding, thereby preventing attacks like SQL injection.
|
|
481
|
+
*
|
|
482
|
+
* The cache has a maxSize that defaults to 1000 statements, but a custom size can
|
|
483
|
+
* be provided (e.g., database.createSQLTagStore(100)). All APIs exposed by this
|
|
484
|
+
* class execute synchronously.
|
|
485
|
+
* @since v24.9.0
|
|
486
|
+
*/
|
|
487
|
+
interface SQLTagStore {
|
|
488
|
+
/**
|
|
489
|
+
* Executes the given SQL query and returns all resulting rows as an array of objects.
|
|
490
|
+
* @since v24.9.0
|
|
491
|
+
*/
|
|
492
|
+
all(
|
|
493
|
+
stringElements: TemplateStringsArray,
|
|
494
|
+
...boundParameters: SQLInputValue[]
|
|
495
|
+
): Record<string, SQLOutputValue>[];
|
|
496
|
+
/**
|
|
497
|
+
* Executes the given SQL query and returns the first resulting row as an object.
|
|
498
|
+
* @since v24.9.0
|
|
499
|
+
*/
|
|
500
|
+
get(
|
|
501
|
+
stringElements: TemplateStringsArray,
|
|
502
|
+
...boundParameters: SQLInputValue[]
|
|
503
|
+
): Record<string, SQLOutputValue> | undefined;
|
|
504
|
+
/**
|
|
505
|
+
* Executes the given SQL query and returns an iterator over the resulting rows.
|
|
506
|
+
* @since v24.9.0
|
|
507
|
+
*/
|
|
508
|
+
iterate(
|
|
509
|
+
stringElements: TemplateStringsArray,
|
|
510
|
+
...boundParameters: SQLInputValue[]
|
|
511
|
+
): NodeJS.Iterator<Record<string, SQLOutputValue>>;
|
|
512
|
+
/**
|
|
513
|
+
* Executes the given SQL query, which is expected to not return any rows (e.g., INSERT, UPDATE, DELETE).
|
|
514
|
+
* @since v24.9.0
|
|
515
|
+
*/
|
|
516
|
+
run(stringElements: TemplateStringsArray, ...boundParameters: SQLInputValue[]): StatementResultingChanges;
|
|
517
|
+
/**
|
|
518
|
+
* A read-only property that returns the number of prepared statements currently in the cache.
|
|
519
|
+
* @since v24.9.0
|
|
520
|
+
* @returns The maximum number of prepared statements the cache can hold.
|
|
521
|
+
*/
|
|
522
|
+
size(): number;
|
|
523
|
+
/**
|
|
524
|
+
* A read-only property that returns the maximum number of prepared statements the cache can hold.
|
|
525
|
+
* @since v24.9.0
|
|
526
|
+
*/
|
|
527
|
+
readonly capacity: number;
|
|
528
|
+
/**
|
|
529
|
+
* A read-only property that returns the `DatabaseSync` object associated with this `SQLTagStore`.
|
|
530
|
+
* @since v24.9.0
|
|
531
|
+
*/
|
|
532
|
+
readonly db: DatabaseSync;
|
|
533
|
+
/**
|
|
534
|
+
* Resets the LRU cache, clearing all stored prepared statements.
|
|
535
|
+
* @since v24.9.0
|
|
536
|
+
*/
|
|
537
|
+
clear(): void;
|
|
538
|
+
}
|
|
431
539
|
interface StatementColumnMetadata {
|
|
432
540
|
/**
|
|
433
541
|
* The unaliased name of the column in the origin
|
node/util.d.ts
CHANGED
|
@@ -853,6 +853,15 @@ declare module "util" {
|
|
|
853
853
|
* @return The deprecated function wrapped to emit a warning.
|
|
854
854
|
*/
|
|
855
855
|
export function deprecate<T extends Function>(fn: T, msg: string, code?: string): T;
|
|
856
|
+
export interface IsDeepStrictEqualOptions {
|
|
857
|
+
/**
|
|
858
|
+
* If `true`, prototype and constructor
|
|
859
|
+
* comparison is skipped during deep strict equality check.
|
|
860
|
+
* @since v24.9.0
|
|
861
|
+
* @default false
|
|
862
|
+
*/
|
|
863
|
+
skipPrototype?: boolean | undefined;
|
|
864
|
+
}
|
|
856
865
|
/**
|
|
857
866
|
* Returns `true` if there is deep strict equality between `val1` and `val2`.
|
|
858
867
|
* Otherwise, returns `false`.
|
|
@@ -861,7 +870,7 @@ declare module "util" {
|
|
|
861
870
|
* equality.
|
|
862
871
|
* @since v9.0.0
|
|
863
872
|
*/
|
|
864
|
-
export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean;
|
|
873
|
+
export function isDeepStrictEqual(val1: unknown, val2: unknown, options?: IsDeepStrictEqualOptions): boolean;
|
|
865
874
|
/**
|
|
866
875
|
* Returns `str` with any ANSI escape codes removed.
|
|
867
876
|
*
|
|
@@ -1442,7 +1451,7 @@ declare module "util" {
|
|
|
1442
1451
|
/**
|
|
1443
1452
|
* Array of argument strings.
|
|
1444
1453
|
*/
|
|
1445
|
-
args?: string[] | undefined;
|
|
1454
|
+
args?: readonly string[] | undefined;
|
|
1446
1455
|
/**
|
|
1447
1456
|
* Used to describe arguments known to the parser.
|
|
1448
1457
|
*/
|
node/v8.d.ts
CHANGED
|
@@ -416,6 +416,22 @@ declare module "v8" {
|
|
|
416
416
|
*/
|
|
417
417
|
[Symbol.asyncDispose](): Promise<void>;
|
|
418
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* @since v24.9.0
|
|
421
|
+
*/
|
|
422
|
+
interface HeapProfileHandle {
|
|
423
|
+
/**
|
|
424
|
+
* Stopping collecting the profile, then return a Promise that fulfills with an error or the
|
|
425
|
+
* profile data.
|
|
426
|
+
* @since v24.9.0
|
|
427
|
+
*/
|
|
428
|
+
stop(): Promise<string>;
|
|
429
|
+
/**
|
|
430
|
+
* Stopping collecting the profile and the profile will be discarded.
|
|
431
|
+
* @since v24.9.0
|
|
432
|
+
*/
|
|
433
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
434
|
+
}
|
|
419
435
|
/**
|
|
420
436
|
* V8 only supports `Latin-1/ISO-8859-1` and `UTF16` as the underlying representation of a string.
|
|
421
437
|
* If the `content` uses `Latin-1/ISO-8859-1` as the underlying representation, this function will return true;
|
node/vm.d.ts
CHANGED
|
@@ -962,6 +962,26 @@ declare module "vm" {
|
|
|
962
962
|
* @deprecated Use `sourceTextModule.moduleRequests` instead.
|
|
963
963
|
*/
|
|
964
964
|
readonly dependencySpecifiers: readonly string[];
|
|
965
|
+
/**
|
|
966
|
+
* Iterates over the dependency graph and returns `true` if any module in its
|
|
967
|
+
* dependencies or this module itself contains top-level `await` expressions,
|
|
968
|
+
* otherwise returns `false`.
|
|
969
|
+
*
|
|
970
|
+
* The search may be slow if the graph is big enough.
|
|
971
|
+
*
|
|
972
|
+
* This requires the module to be instantiated first. If the module is not
|
|
973
|
+
* instantiated yet, an error will be thrown.
|
|
974
|
+
* @since v24.9.0
|
|
975
|
+
*/
|
|
976
|
+
hasAsyncGraph(): boolean;
|
|
977
|
+
/**
|
|
978
|
+
* Returns whether the module itself contains any top-level `await` expressions.
|
|
979
|
+
*
|
|
980
|
+
* This corresponds to the field `[[HasTLA]]` in [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) in the
|
|
981
|
+
* ECMAScript specification.
|
|
982
|
+
* @since v24.9.0
|
|
983
|
+
*/
|
|
984
|
+
hasTopLevelAwait(): boolean;
|
|
965
985
|
/**
|
|
966
986
|
* Instantiate the module with the linked requested modules.
|
|
967
987
|
*
|
node/wasi.d.ts
CHANGED
node/worker_threads.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ declare module "worker_threads" {
|
|
|
62
62
|
import { Readable, Writable } from "node:stream";
|
|
63
63
|
import { ReadableStream, TransformStream, WritableStream } from "node:stream/web";
|
|
64
64
|
import { URL } from "node:url";
|
|
65
|
-
import { CPUProfileHandle, HeapInfo } from "node:v8";
|
|
65
|
+
import { CPUProfileHandle, HeapInfo, HeapProfileHandle } from "node:v8";
|
|
66
66
|
import { MessageEvent } from "undici-types";
|
|
67
67
|
const isInternalThread: boolean;
|
|
68
68
|
const isMainThread: boolean;
|
|
@@ -492,10 +492,10 @@ declare module "worker_threads" {
|
|
|
492
492
|
* `await using` example.
|
|
493
493
|
*
|
|
494
494
|
* ```js
|
|
495
|
-
* const { Worker } = require('node
|
|
495
|
+
* const { Worker } = require('node:worker_threads');
|
|
496
496
|
*
|
|
497
497
|
* const w = new Worker(`
|
|
498
|
-
* const { parentPort } = require('worker_threads');
|
|
498
|
+
* const { parentPort } = require('node:worker_threads');
|
|
499
499
|
* parentPort.on('message', () => {});
|
|
500
500
|
* `, { eval: true });
|
|
501
501
|
*
|
|
@@ -507,6 +507,43 @@ declare module "worker_threads" {
|
|
|
507
507
|
* @since v24.8.0
|
|
508
508
|
*/
|
|
509
509
|
startCpuProfile(): Promise<CPUProfileHandle>;
|
|
510
|
+
/**
|
|
511
|
+
* Starting a Heap profile then return a Promise that fulfills with an error
|
|
512
|
+
* or an `HeapProfileHandle` object. This API supports `await using` syntax.
|
|
513
|
+
*
|
|
514
|
+
* ```js
|
|
515
|
+
* const { Worker } = require('node:worker_threads');
|
|
516
|
+
*
|
|
517
|
+
* const worker = new Worker(`
|
|
518
|
+
* const { parentPort } = require('worker_threads');
|
|
519
|
+
* parentPort.on('message', () => {});
|
|
520
|
+
* `, { eval: true });
|
|
521
|
+
*
|
|
522
|
+
* worker.on('online', async () => {
|
|
523
|
+
* const handle = await worker.startHeapProfile();
|
|
524
|
+
* const profile = await handle.stop();
|
|
525
|
+
* console.log(profile);
|
|
526
|
+
* worker.terminate();
|
|
527
|
+
* });
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* `await using` example.
|
|
531
|
+
*
|
|
532
|
+
* ```js
|
|
533
|
+
* const { Worker } = require('node:worker_threads');
|
|
534
|
+
*
|
|
535
|
+
* const w = new Worker(`
|
|
536
|
+
* const { parentPort } = require('node:worker_threads');
|
|
537
|
+
* parentPort.on('message', () => {});
|
|
538
|
+
* `, { eval: true });
|
|
539
|
+
*
|
|
540
|
+
* w.on('online', async () => {
|
|
541
|
+
* // Stop profile automatically when return and profile will be discarded
|
|
542
|
+
* await using handle = await w.startHeapProfile();
|
|
543
|
+
* });
|
|
544
|
+
* ```
|
|
545
|
+
*/
|
|
546
|
+
startHeapProfile(): Promise<HeapProfileHandle>;
|
|
510
547
|
/**
|
|
511
548
|
* Calls `worker.terminate()` when the dispose scope is exited.
|
|
512
549
|
*
|