@types/node 18.19.14 → 18.19.16
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 v18.19/README.md +1 -1
- node v18.19/package.json +2 -2
- node v18.19/ts4.8/url.d.ts +62 -45
- node v18.19/ts4.8/v8.d.ts +228 -16
- node v18.19/url.d.ts +62 -45
- node v18.19/v8.d.ts +228 -16
node v18.19/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/v18.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated: Thu,
|
|
11
|
+
* Last updated: Thu, 15 Feb 2024 10:07:24 GMT
|
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
|
13
13
|
|
|
14
14
|
# Credits
|
node v18.19/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "18.19.
|
|
3
|
+
"version": "18.19.16",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -229,6 +229,6 @@
|
|
|
229
229
|
"dependencies": {
|
|
230
230
|
"undici-types": "~5.26.4"
|
|
231
231
|
},
|
|
232
|
-
"typesPublisherContentHash": "
|
|
232
|
+
"typesPublisherContentHash": "fc779caf4c4851e599ce7c1f13b85e3f32d200cafac091a78d5f58ff82591bee",
|
|
233
233
|
"typeScriptVersion": "4.6"
|
|
234
234
|
}
|
node v18.19/ts4.8/url.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ```js
|
|
6
6
|
* import url from 'url';
|
|
7
7
|
* ```
|
|
8
|
-
* @see [source](https://github.com/nodejs/node/blob/v18.
|
|
8
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.19.0/lib/url.js)
|
|
9
9
|
*/
|
|
10
10
|
declare module "url" {
|
|
11
11
|
import { Blob as NodeBlob } from "node:buffer";
|
|
@@ -80,18 +80,18 @@ declare module "url" {
|
|
|
80
80
|
function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
|
|
81
81
|
function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
|
|
82
82
|
/**
|
|
83
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
83
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
84
84
|
*
|
|
85
85
|
* ```js
|
|
86
|
-
* const url = require('url');
|
|
86
|
+
* const url = require('node:url');
|
|
87
87
|
* url.format({
|
|
88
88
|
* protocol: 'https',
|
|
89
89
|
* hostname: 'example.com',
|
|
90
90
|
* pathname: '/some/path',
|
|
91
91
|
* query: {
|
|
92
92
|
* page: 1,
|
|
93
|
-
* format: 'json'
|
|
94
|
-
* }
|
|
93
|
+
* format: 'json',
|
|
94
|
+
* },
|
|
95
95
|
* });
|
|
96
96
|
*
|
|
97
97
|
* // => 'https://example.com/some/path?page=1&format=json'
|
|
@@ -106,33 +106,33 @@ declare module "url" {
|
|
|
106
106
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
107
107
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
108
108
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
109
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
109
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
110
110
|
* * `urlObject.slashes` property is true;
|
|
111
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
112
|
-
* * If the value of the `urlObject.auth` property is truthy, and either`urlObject.host` or `urlObject.hostname` are not `undefined`, the value of`urlObject.auth` will be coerced into a string
|
|
113
|
-
* and appended to `result`followed by the literal string `@`.
|
|
111
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
112
|
+
* * If the value of the `urlObject.auth` property is truthy, and either `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of `urlObject.auth` will be coerced into a string
|
|
113
|
+
* and appended to `result` followed by the literal string `@`.
|
|
114
114
|
* * If the `urlObject.host` property is `undefined` then:
|
|
115
115
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
116
116
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
117
117
|
* an `Error` is thrown.
|
|
118
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
118
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
119
119
|
* * The literal string `:` is appended to `result`, and
|
|
120
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
121
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
120
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
121
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
122
122
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
123
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
123
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
124
124
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
125
125
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
126
126
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
127
|
-
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result`followed by the output of calling the
|
|
128
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
127
|
+
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result` followed by the output of calling the
|
|
128
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
129
129
|
* * Otherwise, if `urlObject.search` is a string:
|
|
130
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
130
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
131
131
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
132
132
|
* * The value of `urlObject.search` is appended to `result`.
|
|
133
133
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
134
134
|
* * If the `urlObject.hash` property is a string:
|
|
135
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
135
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
136
136
|
* character, the literal string `#` is appended to `result`.
|
|
137
137
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
138
138
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -144,18 +144,18 @@ declare module "url" {
|
|
|
144
144
|
*/
|
|
145
145
|
function format(urlObject: URL, options?: URLFormatOptions): string;
|
|
146
146
|
/**
|
|
147
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
147
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
148
148
|
*
|
|
149
149
|
* ```js
|
|
150
|
-
* const url = require('url');
|
|
150
|
+
* const url = require('node:url');
|
|
151
151
|
* url.format({
|
|
152
152
|
* protocol: 'https',
|
|
153
153
|
* hostname: 'example.com',
|
|
154
154
|
* pathname: '/some/path',
|
|
155
155
|
* query: {
|
|
156
156
|
* page: 1,
|
|
157
|
-
* format: 'json'
|
|
158
|
-
* }
|
|
157
|
+
* format: 'json',
|
|
158
|
+
* },
|
|
159
159
|
* });
|
|
160
160
|
*
|
|
161
161
|
* // => 'https://example.com/some/path?page=1&format=json'
|
|
@@ -170,33 +170,33 @@ declare module "url" {
|
|
|
170
170
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
171
171
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
172
172
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
173
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
173
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
174
174
|
* * `urlObject.slashes` property is true;
|
|
175
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
176
|
-
* * If the value of the `urlObject.auth` property is truthy, and either`urlObject.host` or `urlObject.hostname` are not `undefined`, the value of`urlObject.auth` will be coerced into a string
|
|
177
|
-
* and appended to `result`followed by the literal string `@`.
|
|
175
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
176
|
+
* * If the value of the `urlObject.auth` property is truthy, and either `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of `urlObject.auth` will be coerced into a string
|
|
177
|
+
* and appended to `result` followed by the literal string `@`.
|
|
178
178
|
* * If the `urlObject.host` property is `undefined` then:
|
|
179
179
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
180
180
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
181
181
|
* an `Error` is thrown.
|
|
182
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
182
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
183
183
|
* * The literal string `:` is appended to `result`, and
|
|
184
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
185
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
184
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
185
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
186
186
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
187
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
187
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
188
188
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
189
189
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
190
190
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
191
|
-
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result`followed by the output of calling the
|
|
192
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
191
|
+
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result` followed by the output of calling the
|
|
192
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
193
193
|
* * Otherwise, if `urlObject.search` is a string:
|
|
194
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
194
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
195
195
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
196
196
|
* * The value of `urlObject.search` is appended to `result`.
|
|
197
197
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
198
198
|
* * If the `urlObject.hash` property is a string:
|
|
199
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
199
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
200
200
|
* character, the literal string `#` is appended to `result`.
|
|
201
201
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
202
202
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -355,9 +355,26 @@ declare module "url" {
|
|
|
355
355
|
*/
|
|
356
356
|
function urlToHttpOptions(url: URL): ClientRequestArgs;
|
|
357
357
|
interface URLFormatOptions {
|
|
358
|
+
/**
|
|
359
|
+
* `true` if the serialized URL string should include the username and password, `false` otherwise.
|
|
360
|
+
* @default true
|
|
361
|
+
*/
|
|
358
362
|
auth?: boolean | undefined;
|
|
363
|
+
/**
|
|
364
|
+
* `true` if the serialized URL string should include the fragment, `false` otherwise.
|
|
365
|
+
* @default true
|
|
366
|
+
*/
|
|
359
367
|
fragment?: boolean | undefined;
|
|
368
|
+
/**
|
|
369
|
+
* `true` if the serialized URL string should include the search query, `false` otherwise.
|
|
370
|
+
* @default true
|
|
371
|
+
*/
|
|
360
372
|
search?: boolean | undefined;
|
|
373
|
+
/**
|
|
374
|
+
* `true` if Unicode characters appearing in the host component of the URL string should be encoded directly as opposed to
|
|
375
|
+
* being Punycode encoded.
|
|
376
|
+
* @default false
|
|
377
|
+
*/
|
|
361
378
|
unicode?: boolean | undefined;
|
|
362
379
|
}
|
|
363
380
|
/**
|
|
@@ -367,7 +384,7 @@ declare module "url" {
|
|
|
367
384
|
*
|
|
368
385
|
* In accordance with browser conventions, all properties of `URL` objects
|
|
369
386
|
* are implemented as getters and setters on the class prototype, rather than as
|
|
370
|
-
* data properties on the object itself. Thus, unlike `legacy urlObject`
|
|
387
|
+
* data properties on the object itself. Thus, unlike `legacy urlObject`s,
|
|
371
388
|
* using the `delete` keyword on any properties of `URL` objects (e.g. `delete myURL.protocol`, `delete myURL.pathname`, etc) has no effect but will still
|
|
372
389
|
* return `true`.
|
|
373
390
|
* @since v7.0.0, v6.13.0
|
|
@@ -391,7 +408,7 @@ declare module "url" {
|
|
|
391
408
|
* console.log(otherBlob.size);
|
|
392
409
|
* ```
|
|
393
410
|
*
|
|
394
|
-
* The data stored by the registered `Blob` will be retained in memory until`URL.revokeObjectURL()` is called to remove it.
|
|
411
|
+
* The data stored by the registered `Blob` will be retained in memory until `URL.revokeObjectURL()` is called to remove it.
|
|
395
412
|
*
|
|
396
413
|
* `Blob` objects are registered within the current thread. If using Worker
|
|
397
414
|
* Threads, `Blob` objects registered within one Worker will not be available
|
|
@@ -407,7 +424,7 @@ declare module "url" {
|
|
|
407
424
|
* @experimental
|
|
408
425
|
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
|
409
426
|
*/
|
|
410
|
-
static revokeObjectURL(
|
|
427
|
+
static revokeObjectURL(id: string): void;
|
|
411
428
|
/**
|
|
412
429
|
* Checks if an `input` relative to the `base` can be parsed to a `URL`.
|
|
413
430
|
*
|
|
@@ -422,7 +439,7 @@ declare module "url" {
|
|
|
422
439
|
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
|
|
423
440
|
*/
|
|
424
441
|
static canParse(input: string, base?: string): boolean;
|
|
425
|
-
constructor(input: string, base?: string | URL);
|
|
442
|
+
constructor(input: string | { toString: () => string }, base?: string | URL);
|
|
426
443
|
/**
|
|
427
444
|
* Gets and sets the fragment portion of the URL.
|
|
428
445
|
*
|
|
@@ -551,14 +568,14 @@ declare module "url" {
|
|
|
551
568
|
* // Prints https://example.org/abcdef?123
|
|
552
569
|
* ```
|
|
553
570
|
*
|
|
554
|
-
* Invalid URL characters included in the value assigned to the `pathname`property are `percent-encoded`. The selection of which characters
|
|
571
|
+
* Invalid URL characters included in the value assigned to the `pathname` property are `percent-encoded`. The selection of which characters
|
|
555
572
|
* to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
556
573
|
*/
|
|
557
574
|
pathname: string;
|
|
558
575
|
/**
|
|
559
576
|
* Gets and sets the port portion of the URL.
|
|
560
577
|
*
|
|
561
|
-
* The port value may be a number or a string containing a number in the range`0` to `65535` (inclusive). Setting the value to the default port of the`URL` objects given `protocol` will
|
|
578
|
+
* The port value may be a number or a string containing a number in the range `0` to `65535` (inclusive). Setting the value to the default port of the `URL` objects given `protocol` will
|
|
562
579
|
* result in the `port` value becoming
|
|
563
580
|
* the empty string (`''`).
|
|
564
581
|
*
|
|
@@ -698,7 +715,7 @@ declare module "url" {
|
|
|
698
715
|
* // Prints https://123:xyz@example.com/
|
|
699
716
|
* ```
|
|
700
717
|
*
|
|
701
|
-
* Any invalid URL characters appearing in the value assigned the `username`property will be `percent-encoded`. The selection of which
|
|
718
|
+
* Any invalid URL characters appearing in the value assigned the `username` property will be `percent-encoded`. The selection of which
|
|
702
719
|
* characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
703
720
|
*/
|
|
704
721
|
username: string;
|
|
@@ -726,7 +743,7 @@ declare module "url" {
|
|
|
726
743
|
toJSON(): string;
|
|
727
744
|
}
|
|
728
745
|
/**
|
|
729
|
-
* The `URLSearchParams` API provides read and write access to the query of a`URL`. The `URLSearchParams` class can also be used standalone with one of the
|
|
746
|
+
* The `URLSearchParams` API provides read and write access to the query of a `URL`. The `URLSearchParams` class can also be used standalone with one of the
|
|
730
747
|
* four following constructors.
|
|
731
748
|
* The `URLSearchParams` class is also available on the global object.
|
|
732
749
|
*
|
|
@@ -784,14 +801,14 @@ declare module "url" {
|
|
|
784
801
|
append(name: string, value: string): void;
|
|
785
802
|
/**
|
|
786
803
|
* If `value` is provided, removes all name-value pairs
|
|
787
|
-
* where name is `name` and value is `value
|
|
804
|
+
* where name is `name` and value is `value`.
|
|
788
805
|
*
|
|
789
806
|
* If `value` is not provided, removes all name-value pairs whose name is `name`.
|
|
790
807
|
*/
|
|
791
808
|
delete(name: string, value?: string): void;
|
|
792
809
|
/**
|
|
793
810
|
* Returns an ES6 `Iterator` over each of the name-value pairs in the query.
|
|
794
|
-
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array`is the `name`, the second item of the `Array` is the `value`.
|
|
811
|
+
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array` is the `name`, the second item of the `Array` is the `value`.
|
|
795
812
|
*
|
|
796
813
|
* Alias for `urlSearchParams[@@iterator]()`.
|
|
797
814
|
*/
|
|
@@ -812,7 +829,7 @@ declare module "url" {
|
|
|
812
829
|
* @param thisArg To be used as `this` value for when `fn` is called
|
|
813
830
|
*/
|
|
814
831
|
forEach<TThis = this>(
|
|
815
|
-
|
|
832
|
+
fn: (this: TThis, value: string, name: string, searchParams: URLSearchParams) => void,
|
|
816
833
|
thisArg?: TThis,
|
|
817
834
|
): void;
|
|
818
835
|
/**
|
|
@@ -827,7 +844,7 @@ declare module "url" {
|
|
|
827
844
|
*/
|
|
828
845
|
getAll(name: string): string[];
|
|
829
846
|
/**
|
|
830
|
-
* Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument.
|
|
847
|
+
* Checks if the `URLSearchParams` object contains key-value pair(s) based on `name` and an optional `value` argument.
|
|
831
848
|
*
|
|
832
849
|
* If `value` is provided, returns `true` when name-value pair with
|
|
833
850
|
* same `name` and `value` exists.
|
node v18.19/ts4.8/v8.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `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:
|
|
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
|
-
* const v8 = require('v8');
|
|
5
|
+
* const v8 = require('node:v8');
|
|
6
6
|
* ```
|
|
7
|
-
* @see [source](https://github.com/nodejs/node/blob/v18.
|
|
7
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.19.0/lib/v8.js)
|
|
8
8
|
*/
|
|
9
9
|
declare module "v8" {
|
|
10
10
|
import { Readable } from "node:stream";
|
|
@@ -29,6 +29,9 @@ declare module "v8" {
|
|
|
29
29
|
does_zap_garbage: DoesZapCodeSpaceFlag;
|
|
30
30
|
number_of_native_contexts: number;
|
|
31
31
|
number_of_detached_contexts: number;
|
|
32
|
+
total_global_handles_size: number;
|
|
33
|
+
used_global_handles_size: number;
|
|
34
|
+
external_memory: number;
|
|
32
35
|
}
|
|
33
36
|
interface HeapCodeStatistics {
|
|
34
37
|
code_and_metadata_size: number;
|
|
@@ -68,6 +71,15 @@ declare module "v8" {
|
|
|
68
71
|
* of contexts that were detached and not yet garbage collected. This number
|
|
69
72
|
* being non-zero indicates a potential memory leak.
|
|
70
73
|
*
|
|
74
|
+
* `total_global_handles_size` The value of total\_global\_handles\_size is the
|
|
75
|
+
* total memory size of V8 global handles.
|
|
76
|
+
*
|
|
77
|
+
* `used_global_handles_size` The value of used\_global\_handles\_size is the
|
|
78
|
+
* used memory size of V8 global handles.
|
|
79
|
+
*
|
|
80
|
+
* `external_memory` The value of external\_memory is the memory size of array
|
|
81
|
+
* buffers and external strings.
|
|
82
|
+
*
|
|
71
83
|
* ```js
|
|
72
84
|
* {
|
|
73
85
|
* total_heap_size: 7326976,
|
|
@@ -80,7 +92,10 @@ declare module "v8" {
|
|
|
80
92
|
* peak_malloced_memory: 1127496,
|
|
81
93
|
* does_zap_garbage: 0,
|
|
82
94
|
* number_of_native_contexts: 1,
|
|
83
|
-
* number_of_detached_contexts: 0
|
|
95
|
+
* number_of_detached_contexts: 0,
|
|
96
|
+
* total_global_handles_size: 8192,
|
|
97
|
+
* used_global_handles_size: 3296,
|
|
98
|
+
* external_memory: 318824
|
|
84
99
|
* }
|
|
85
100
|
* ```
|
|
86
101
|
* @since v1.0.0
|
|
@@ -90,7 +105,7 @@ declare module "v8" {
|
|
|
90
105
|
* Returns statistics about the V8 heap spaces, i.e. the segments which make up
|
|
91
106
|
* the V8 heap. Neither the ordering of heap spaces, nor the availability of a
|
|
92
107
|
* heap space can be guaranteed as the statistics are provided via the
|
|
93
|
-
* V8[`GetHeapSpaceStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4) function and may change from one V8 version to the
|
|
108
|
+
* V8 [`GetHeapSpaceStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4) function and may change from one V8 version to the
|
|
94
109
|
* next.
|
|
95
110
|
*
|
|
96
111
|
* The value returned is an array of objects containing the following properties:
|
|
@@ -149,7 +164,7 @@ declare module "v8" {
|
|
|
149
164
|
*
|
|
150
165
|
* ```js
|
|
151
166
|
* // Print GC events to stdout for one minute.
|
|
152
|
-
* const v8 = require('v8');
|
|
167
|
+
* const v8 = require('node:v8');
|
|
153
168
|
* v8.setFlagsFromString('--trace_gc');
|
|
154
169
|
* setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
|
|
155
170
|
* ```
|
|
@@ -172,7 +187,7 @@ declare module "v8" {
|
|
|
172
187
|
*
|
|
173
188
|
* ```js
|
|
174
189
|
* // Print heap snapshot to the console
|
|
175
|
-
* const v8 = require('v8');
|
|
190
|
+
* const v8 = require('node:v8');
|
|
176
191
|
* const stream = v8.getHeapSnapshot();
|
|
177
192
|
* stream.pipe(process.stdout);
|
|
178
193
|
* ```
|
|
@@ -197,12 +212,12 @@ declare module "v8" {
|
|
|
197
212
|
* for a duration depending on the heap size.
|
|
198
213
|
*
|
|
199
214
|
* ```js
|
|
200
|
-
* const { writeHeapSnapshot } = require('v8');
|
|
215
|
+
* const { writeHeapSnapshot } = require('node:v8');
|
|
201
216
|
* const {
|
|
202
217
|
* Worker,
|
|
203
218
|
* isMainThread,
|
|
204
|
-
* parentPort
|
|
205
|
-
* } = require('worker_threads');
|
|
219
|
+
* parentPort,
|
|
220
|
+
* } = require('node:worker_threads');
|
|
206
221
|
*
|
|
207
222
|
* if (isMainThread) {
|
|
208
223
|
* const worker = new Worker(__filename);
|
|
@@ -233,13 +248,16 @@ declare module "v8" {
|
|
|
233
248
|
*/
|
|
234
249
|
function writeHeapSnapshot(filename?: string): string;
|
|
235
250
|
/**
|
|
236
|
-
*
|
|
251
|
+
* Get statistics about code and its metadata in the heap, see
|
|
252
|
+
* V8 [`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the
|
|
253
|
+
* following properties:
|
|
237
254
|
*
|
|
238
255
|
* ```js
|
|
239
256
|
* {
|
|
240
257
|
* code_and_metadata_size: 212208,
|
|
241
258
|
* bytecode_and_metadata_size: 161368,
|
|
242
|
-
* external_script_source_size: 1410794
|
|
259
|
+
* external_script_source_size: 1410794,
|
|
260
|
+
* cpu_profiler_metadata_size: 0,
|
|
243
261
|
* }
|
|
244
262
|
* ```
|
|
245
263
|
* @since v12.8.0
|
|
@@ -289,7 +307,7 @@ declare module "v8" {
|
|
|
289
307
|
*/
|
|
290
308
|
writeDouble(value: number): void;
|
|
291
309
|
/**
|
|
292
|
-
* Write raw bytes into the serializer
|
|
310
|
+
* Write raw bytes into the serializer's internal buffer. The deserializer
|
|
293
311
|
* will require a way to compute the length of the buffer.
|
|
294
312
|
* For use inside of a custom `serializer._writeHostObject()`.
|
|
295
313
|
*/
|
|
@@ -345,7 +363,7 @@ declare module "v8" {
|
|
|
345
363
|
*/
|
|
346
364
|
readDouble(): number;
|
|
347
365
|
/**
|
|
348
|
-
* Read raw bytes from the deserializer
|
|
366
|
+
* Read raw bytes from the deserializer's internal buffer. The `length` parameter
|
|
349
367
|
* must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`.
|
|
350
368
|
* For use inside of a custom `deserializer._readHostObject()`.
|
|
351
369
|
*/
|
|
@@ -390,17 +408,100 @@ declare module "v8" {
|
|
|
390
408
|
* @since v15.1.0, v14.18.0, v12.22.0
|
|
391
409
|
*/
|
|
392
410
|
function stopCoverage(): void;
|
|
393
|
-
|
|
411
|
+
/**
|
|
412
|
+
* The API is a no-op if `--heapsnapshot-near-heap-limit` is already set from the command line or the API is called more than once.
|
|
413
|
+
* `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-v18.x/api/cli.html#--heapsnapshot-near-heap-limitmax_count) for more information.
|
|
414
|
+
* @experimental
|
|
415
|
+
* @since v18.10.0, v16.18.0
|
|
416
|
+
*/
|
|
417
|
+
function setHeapSnapshotNearHeapLimit(limit: number): void;
|
|
394
418
|
/**
|
|
395
419
|
* This API collects GC data in current thread.
|
|
420
|
+
* @since v18.15.0
|
|
396
421
|
*/
|
|
397
422
|
class GCProfiler {
|
|
398
423
|
/**
|
|
399
424
|
* Start collecting GC data.
|
|
425
|
+
* @since v18.15.0
|
|
400
426
|
*/
|
|
401
427
|
start(): void;
|
|
402
428
|
/**
|
|
403
|
-
* Stop collecting GC data and return
|
|
429
|
+
* Stop collecting GC data and return an object.The content of object
|
|
430
|
+
* is as follows.
|
|
431
|
+
*
|
|
432
|
+
* ```json
|
|
433
|
+
* {
|
|
434
|
+
* "version": 1,
|
|
435
|
+
* "startTime": 1674059033862,
|
|
436
|
+
* "statistics": [
|
|
437
|
+
* {
|
|
438
|
+
* "gcType": "Scavenge",
|
|
439
|
+
* "beforeGC": {
|
|
440
|
+
* "heapStatistics": {
|
|
441
|
+
* "totalHeapSize": 5005312,
|
|
442
|
+
* "totalHeapSizeExecutable": 524288,
|
|
443
|
+
* "totalPhysicalSize": 5226496,
|
|
444
|
+
* "totalAvailableSize": 4341325216,
|
|
445
|
+
* "totalGlobalHandlesSize": 8192,
|
|
446
|
+
* "usedGlobalHandlesSize": 2112,
|
|
447
|
+
* "usedHeapSize": 4883840,
|
|
448
|
+
* "heapSizeLimit": 4345298944,
|
|
449
|
+
* "mallocedMemory": 254128,
|
|
450
|
+
* "externalMemory": 225138,
|
|
451
|
+
* "peakMallocedMemory": 181760
|
|
452
|
+
* },
|
|
453
|
+
* "heapSpaceStatistics": [
|
|
454
|
+
* {
|
|
455
|
+
* "spaceName": "read_only_space",
|
|
456
|
+
* "spaceSize": 0,
|
|
457
|
+
* "spaceUsedSize": 0,
|
|
458
|
+
* "spaceAvailableSize": 0,
|
|
459
|
+
* "physicalSpaceSize": 0
|
|
460
|
+
* }
|
|
461
|
+
* ]
|
|
462
|
+
* },
|
|
463
|
+
* "cost": 1574.14,
|
|
464
|
+
* "afterGC": {
|
|
465
|
+
* "heapStatistics": {
|
|
466
|
+
* "totalHeapSize": 6053888,
|
|
467
|
+
* "totalHeapSizeExecutable": 524288,
|
|
468
|
+
* "totalPhysicalSize": 5500928,
|
|
469
|
+
* "totalAvailableSize": 4341101384,
|
|
470
|
+
* "totalGlobalHandlesSize": 8192,
|
|
471
|
+
* "usedGlobalHandlesSize": 2112,
|
|
472
|
+
* "usedHeapSize": 4059096,
|
|
473
|
+
* "heapSizeLimit": 4345298944,
|
|
474
|
+
* "mallocedMemory": 254128,
|
|
475
|
+
* "externalMemory": 225138,
|
|
476
|
+
* "peakMallocedMemory": 181760
|
|
477
|
+
* },
|
|
478
|
+
* "heapSpaceStatistics": [
|
|
479
|
+
* {
|
|
480
|
+
* "spaceName": "read_only_space",
|
|
481
|
+
* "spaceSize": 0,
|
|
482
|
+
* "spaceUsedSize": 0,
|
|
483
|
+
* "spaceAvailableSize": 0,
|
|
484
|
+
* "physicalSpaceSize": 0
|
|
485
|
+
* }
|
|
486
|
+
* ]
|
|
487
|
+
* }
|
|
488
|
+
* }
|
|
489
|
+
* ],
|
|
490
|
+
* "endTime": 1674059036865
|
|
491
|
+
* }
|
|
492
|
+
* ```
|
|
493
|
+
*
|
|
494
|
+
* Here's an example.
|
|
495
|
+
*
|
|
496
|
+
* ```js
|
|
497
|
+
* const { GCProfiler } = require('v8');
|
|
498
|
+
* const profiler = new GCProfiler();
|
|
499
|
+
* profiler.start();
|
|
500
|
+
* setTimeout(() => {
|
|
501
|
+
* console.log(profiler.stop());
|
|
502
|
+
* }, 1000);
|
|
503
|
+
* ```
|
|
504
|
+
* @since v18.15.0
|
|
404
505
|
*/
|
|
405
506
|
stop(): GCProfilerResult;
|
|
406
507
|
}
|
|
@@ -535,6 +636,117 @@ declare module "v8" {
|
|
|
535
636
|
* @since v17.1.0, v16.14.0
|
|
536
637
|
*/
|
|
537
638
|
const promiseHooks: PromiseHooks;
|
|
639
|
+
type StartupSnapshotCallbackFn = (args: any) => any;
|
|
640
|
+
interface StartupSnapshot {
|
|
641
|
+
/**
|
|
642
|
+
* Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
|
|
643
|
+
* This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.
|
|
644
|
+
* @since v18.6.0, v16.17.0
|
|
645
|
+
*/
|
|
646
|
+
addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
647
|
+
/**
|
|
648
|
+
* Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
|
|
649
|
+
* The `callback` and the `data` (if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or
|
|
650
|
+
* to re-acquire resources that the application needs when the application is restarted from the snapshot.
|
|
651
|
+
* @since v18.6.0, v16.17.0
|
|
652
|
+
*/
|
|
653
|
+
addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
654
|
+
/**
|
|
655
|
+
* This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script.
|
|
656
|
+
* If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized
|
|
657
|
+
* data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
|
|
658
|
+
* @since v18.6.0, v16.17.0
|
|
659
|
+
*/
|
|
660
|
+
setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
661
|
+
/**
|
|
662
|
+
* Returns true if the Node.js instance is run to build a snapshot.
|
|
663
|
+
* @since v18.6.0, v16.17.0
|
|
664
|
+
*/
|
|
665
|
+
isBuildingSnapshot(): boolean;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* The `v8.startupSnapshot` interface can be used to add serialization and deserialization hooks for custom startup snapshots.
|
|
669
|
+
*
|
|
670
|
+
* ```bash
|
|
671
|
+
* $ node --snapshot-blob snapshot.blob --build-snapshot entry.js
|
|
672
|
+
* # This launches a process with the snapshot
|
|
673
|
+
* $ node --snapshot-blob snapshot.blob
|
|
674
|
+
* ```
|
|
675
|
+
*
|
|
676
|
+
* In the example above, `entry.js` can use methods from the `v8.startupSnapshot` interface to specify how to save information for custom objects
|
|
677
|
+
* in the snapshot during serialization
|
|
678
|
+
* and how the information can be used to synchronize these objects during deserialization of the snapshot.
|
|
679
|
+
* For example, if the `entry.js` contains the following script:
|
|
680
|
+
*
|
|
681
|
+
* ```js
|
|
682
|
+
* 'use strict';
|
|
683
|
+
*
|
|
684
|
+
* const fs = require('node:fs');
|
|
685
|
+
* const zlib = require('node:zlib');
|
|
686
|
+
* const path = require('node:path');
|
|
687
|
+
* const assert = require('node:assert');
|
|
688
|
+
*
|
|
689
|
+
* const v8 = require('node:v8');
|
|
690
|
+
*
|
|
691
|
+
* class BookShelf {
|
|
692
|
+
* storage = new Map();
|
|
693
|
+
*
|
|
694
|
+
* // Reading a series of files from directory and store them into storage.
|
|
695
|
+
* constructor(directory, books) {
|
|
696
|
+
* for (const book of books) {
|
|
697
|
+
* this.storage.set(book, fs.readFileSync(path.join(directory, book)));
|
|
698
|
+
* }
|
|
699
|
+
* }
|
|
700
|
+
*
|
|
701
|
+
* static compressAll(shelf) {
|
|
702
|
+
* for (const [ book, content ] of shelf.storage) {
|
|
703
|
+
* shelf.storage.set(book, zlib.gzipSync(content));
|
|
704
|
+
* }
|
|
705
|
+
* }
|
|
706
|
+
*
|
|
707
|
+
* static decompressAll(shelf) {
|
|
708
|
+
* for (const [ book, content ] of shelf.storage) {
|
|
709
|
+
* shelf.storage.set(book, zlib.gunzipSync(content));
|
|
710
|
+
* }
|
|
711
|
+
* }
|
|
712
|
+
* }
|
|
713
|
+
*
|
|
714
|
+
* // __dirname here is where the snapshot script is placed
|
|
715
|
+
* // during snapshot building time.
|
|
716
|
+
* const shelf = new BookShelf(__dirname, [
|
|
717
|
+
* 'book1.en_US.txt',
|
|
718
|
+
* 'book1.es_ES.txt',
|
|
719
|
+
* 'book2.zh_CN.txt',
|
|
720
|
+
* ]);
|
|
721
|
+
*
|
|
722
|
+
* assert(v8.startupSnapshot.isBuildingSnapshot());
|
|
723
|
+
* // On snapshot serialization, compress the books to reduce size.
|
|
724
|
+
* v8.startupSnapshot.addSerializeCallback(BookShelf.compressAll, shelf);
|
|
725
|
+
* // On snapshot deserialization, decompress the books.
|
|
726
|
+
* v8.startupSnapshot.addDeserializeCallback(BookShelf.decompressAll, shelf);
|
|
727
|
+
* v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
|
|
728
|
+
* // process.env and process.argv are refreshed during snapshot
|
|
729
|
+
* // deserialization.
|
|
730
|
+
* const lang = process.env.BOOK_LANG || 'en_US';
|
|
731
|
+
* const book = process.argv[1];
|
|
732
|
+
* const name = `${book}.${lang}.txt`;
|
|
733
|
+
* console.log(shelf.storage.get(name));
|
|
734
|
+
* }, shelf);
|
|
735
|
+
* ```
|
|
736
|
+
*
|
|
737
|
+
* The resulted binary will get print the data deserialized from the snapshot during start up, using the refreshed `process.env` and `process.argv` of the launched process:
|
|
738
|
+
*
|
|
739
|
+
* ```bash
|
|
740
|
+
* $ BOOK_LANG=es_ES node --snapshot-blob snapshot.blob book1
|
|
741
|
+
* # Prints content of book1.es_ES.txt deserialized from the snapshot.
|
|
742
|
+
* ```
|
|
743
|
+
*
|
|
744
|
+
* Currently the application deserialized from a user-land snapshot cannot be snapshotted again, so these APIs are only available to applications that are not deserialized from a user-land snapshot.
|
|
745
|
+
*
|
|
746
|
+
* @experimental
|
|
747
|
+
* @since v18.6.0, v16.17.0
|
|
748
|
+
*/
|
|
749
|
+
const startupSnapshot: StartupSnapshot;
|
|
538
750
|
}
|
|
539
751
|
declare module "node:v8" {
|
|
540
752
|
export * from "v8";
|
node v18.19/url.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ```js
|
|
6
6
|
* import url from 'url';
|
|
7
7
|
* ```
|
|
8
|
-
* @see [source](https://github.com/nodejs/node/blob/v18.
|
|
8
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.19.0/lib/url.js)
|
|
9
9
|
*/
|
|
10
10
|
declare module "url" {
|
|
11
11
|
import { Blob as NodeBlob } from "node:buffer";
|
|
@@ -80,18 +80,18 @@ declare module "url" {
|
|
|
80
80
|
function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
|
|
81
81
|
function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
|
|
82
82
|
/**
|
|
83
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
83
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
84
84
|
*
|
|
85
85
|
* ```js
|
|
86
|
-
* const url = require('url');
|
|
86
|
+
* const url = require('node:url');
|
|
87
87
|
* url.format({
|
|
88
88
|
* protocol: 'https',
|
|
89
89
|
* hostname: 'example.com',
|
|
90
90
|
* pathname: '/some/path',
|
|
91
91
|
* query: {
|
|
92
92
|
* page: 1,
|
|
93
|
-
* format: 'json'
|
|
94
|
-
* }
|
|
93
|
+
* format: 'json',
|
|
94
|
+
* },
|
|
95
95
|
* });
|
|
96
96
|
*
|
|
97
97
|
* // => 'https://example.com/some/path?page=1&format=json'
|
|
@@ -106,33 +106,33 @@ declare module "url" {
|
|
|
106
106
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
107
107
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
108
108
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
109
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
109
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
110
110
|
* * `urlObject.slashes` property is true;
|
|
111
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
112
|
-
* * If the value of the `urlObject.auth` property is truthy, and either`urlObject.host` or `urlObject.hostname` are not `undefined`, the value of`urlObject.auth` will be coerced into a string
|
|
113
|
-
* and appended to `result`followed by the literal string `@`.
|
|
111
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
112
|
+
* * If the value of the `urlObject.auth` property is truthy, and either `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of `urlObject.auth` will be coerced into a string
|
|
113
|
+
* and appended to `result` followed by the literal string `@`.
|
|
114
114
|
* * If the `urlObject.host` property is `undefined` then:
|
|
115
115
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
116
116
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
117
117
|
* an `Error` is thrown.
|
|
118
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
118
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
119
119
|
* * The literal string `:` is appended to `result`, and
|
|
120
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
121
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
120
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
121
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
122
122
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
123
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
123
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
124
124
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
125
125
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
126
126
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
127
|
-
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result`followed by the output of calling the
|
|
128
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
127
|
+
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result` followed by the output of calling the
|
|
128
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
129
129
|
* * Otherwise, if `urlObject.search` is a string:
|
|
130
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
130
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
131
131
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
132
132
|
* * The value of `urlObject.search` is appended to `result`.
|
|
133
133
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
134
134
|
* * If the `urlObject.hash` property is a string:
|
|
135
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
135
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
136
136
|
* character, the literal string `#` is appended to `result`.
|
|
137
137
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
138
138
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -144,18 +144,18 @@ declare module "url" {
|
|
|
144
144
|
*/
|
|
145
145
|
function format(urlObject: URL, options?: URLFormatOptions): string;
|
|
146
146
|
/**
|
|
147
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
147
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
148
148
|
*
|
|
149
149
|
* ```js
|
|
150
|
-
* const url = require('url');
|
|
150
|
+
* const url = require('node:url');
|
|
151
151
|
* url.format({
|
|
152
152
|
* protocol: 'https',
|
|
153
153
|
* hostname: 'example.com',
|
|
154
154
|
* pathname: '/some/path',
|
|
155
155
|
* query: {
|
|
156
156
|
* page: 1,
|
|
157
|
-
* format: 'json'
|
|
158
|
-
* }
|
|
157
|
+
* format: 'json',
|
|
158
|
+
* },
|
|
159
159
|
* });
|
|
160
160
|
*
|
|
161
161
|
* // => 'https://example.com/some/path?page=1&format=json'
|
|
@@ -170,33 +170,33 @@ declare module "url" {
|
|
|
170
170
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
171
171
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
172
172
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
173
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
173
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
174
174
|
* * `urlObject.slashes` property is true;
|
|
175
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
176
|
-
* * If the value of the `urlObject.auth` property is truthy, and either`urlObject.host` or `urlObject.hostname` are not `undefined`, the value of`urlObject.auth` will be coerced into a string
|
|
177
|
-
* and appended to `result`followed by the literal string `@`.
|
|
175
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
176
|
+
* * If the value of the `urlObject.auth` property is truthy, and either `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of `urlObject.auth` will be coerced into a string
|
|
177
|
+
* and appended to `result` followed by the literal string `@`.
|
|
178
178
|
* * If the `urlObject.host` property is `undefined` then:
|
|
179
179
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
180
180
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
181
181
|
* an `Error` is thrown.
|
|
182
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
182
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
183
183
|
* * The literal string `:` is appended to `result`, and
|
|
184
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
185
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
184
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
185
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
186
186
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
187
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
187
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
188
188
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
189
189
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
190
190
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
191
|
-
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result`followed by the output of calling the
|
|
192
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
191
|
+
* * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result` followed by the output of calling the
|
|
192
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
193
193
|
* * Otherwise, if `urlObject.search` is a string:
|
|
194
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
194
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
195
195
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
196
196
|
* * The value of `urlObject.search` is appended to `result`.
|
|
197
197
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
198
198
|
* * If the `urlObject.hash` property is a string:
|
|
199
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
199
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
200
200
|
* character, the literal string `#` is appended to `result`.
|
|
201
201
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
202
202
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -355,9 +355,26 @@ declare module "url" {
|
|
|
355
355
|
*/
|
|
356
356
|
function urlToHttpOptions(url: URL): ClientRequestArgs;
|
|
357
357
|
interface URLFormatOptions {
|
|
358
|
+
/**
|
|
359
|
+
* `true` if the serialized URL string should include the username and password, `false` otherwise.
|
|
360
|
+
* @default true
|
|
361
|
+
*/
|
|
358
362
|
auth?: boolean | undefined;
|
|
363
|
+
/**
|
|
364
|
+
* `true` if the serialized URL string should include the fragment, `false` otherwise.
|
|
365
|
+
* @default true
|
|
366
|
+
*/
|
|
359
367
|
fragment?: boolean | undefined;
|
|
368
|
+
/**
|
|
369
|
+
* `true` if the serialized URL string should include the search query, `false` otherwise.
|
|
370
|
+
* @default true
|
|
371
|
+
*/
|
|
360
372
|
search?: boolean | undefined;
|
|
373
|
+
/**
|
|
374
|
+
* `true` if Unicode characters appearing in the host component of the URL string should be encoded directly as opposed to
|
|
375
|
+
* being Punycode encoded.
|
|
376
|
+
* @default false
|
|
377
|
+
*/
|
|
361
378
|
unicode?: boolean | undefined;
|
|
362
379
|
}
|
|
363
380
|
/**
|
|
@@ -367,7 +384,7 @@ declare module "url" {
|
|
|
367
384
|
*
|
|
368
385
|
* In accordance with browser conventions, all properties of `URL` objects
|
|
369
386
|
* are implemented as getters and setters on the class prototype, rather than as
|
|
370
|
-
* data properties on the object itself. Thus, unlike `legacy urlObject`
|
|
387
|
+
* data properties on the object itself. Thus, unlike `legacy urlObject`s,
|
|
371
388
|
* using the `delete` keyword on any properties of `URL` objects (e.g. `delete myURL.protocol`, `delete myURL.pathname`, etc) has no effect but will still
|
|
372
389
|
* return `true`.
|
|
373
390
|
* @since v7.0.0, v6.13.0
|
|
@@ -391,7 +408,7 @@ declare module "url" {
|
|
|
391
408
|
* console.log(otherBlob.size);
|
|
392
409
|
* ```
|
|
393
410
|
*
|
|
394
|
-
* The data stored by the registered `Blob` will be retained in memory until`URL.revokeObjectURL()` is called to remove it.
|
|
411
|
+
* The data stored by the registered `Blob` will be retained in memory until `URL.revokeObjectURL()` is called to remove it.
|
|
395
412
|
*
|
|
396
413
|
* `Blob` objects are registered within the current thread. If using Worker
|
|
397
414
|
* Threads, `Blob` objects registered within one Worker will not be available
|
|
@@ -407,7 +424,7 @@ declare module "url" {
|
|
|
407
424
|
* @experimental
|
|
408
425
|
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
|
409
426
|
*/
|
|
410
|
-
static revokeObjectURL(
|
|
427
|
+
static revokeObjectURL(id: string): void;
|
|
411
428
|
/**
|
|
412
429
|
* Checks if an `input` relative to the `base` can be parsed to a `URL`.
|
|
413
430
|
*
|
|
@@ -422,7 +439,7 @@ declare module "url" {
|
|
|
422
439
|
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
|
|
423
440
|
*/
|
|
424
441
|
static canParse(input: string, base?: string): boolean;
|
|
425
|
-
constructor(input: string, base?: string | URL);
|
|
442
|
+
constructor(input: string | { toString: () => string }, base?: string | URL);
|
|
426
443
|
/**
|
|
427
444
|
* Gets and sets the fragment portion of the URL.
|
|
428
445
|
*
|
|
@@ -551,14 +568,14 @@ declare module "url" {
|
|
|
551
568
|
* // Prints https://example.org/abcdef?123
|
|
552
569
|
* ```
|
|
553
570
|
*
|
|
554
|
-
* Invalid URL characters included in the value assigned to the `pathname`property are `percent-encoded`. The selection of which characters
|
|
571
|
+
* Invalid URL characters included in the value assigned to the `pathname` property are `percent-encoded`. The selection of which characters
|
|
555
572
|
* to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
556
573
|
*/
|
|
557
574
|
pathname: string;
|
|
558
575
|
/**
|
|
559
576
|
* Gets and sets the port portion of the URL.
|
|
560
577
|
*
|
|
561
|
-
* The port value may be a number or a string containing a number in the range`0` to `65535` (inclusive). Setting the value to the default port of the`URL` objects given `protocol` will
|
|
578
|
+
* The port value may be a number or a string containing a number in the range `0` to `65535` (inclusive). Setting the value to the default port of the `URL` objects given `protocol` will
|
|
562
579
|
* result in the `port` value becoming
|
|
563
580
|
* the empty string (`''`).
|
|
564
581
|
*
|
|
@@ -698,7 +715,7 @@ declare module "url" {
|
|
|
698
715
|
* // Prints https://123:xyz@example.com/
|
|
699
716
|
* ```
|
|
700
717
|
*
|
|
701
|
-
* Any invalid URL characters appearing in the value assigned the `username`property will be `percent-encoded`. The selection of which
|
|
718
|
+
* Any invalid URL characters appearing in the value assigned the `username` property will be `percent-encoded`. The selection of which
|
|
702
719
|
* characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
703
720
|
*/
|
|
704
721
|
username: string;
|
|
@@ -726,7 +743,7 @@ declare module "url" {
|
|
|
726
743
|
toJSON(): string;
|
|
727
744
|
}
|
|
728
745
|
/**
|
|
729
|
-
* The `URLSearchParams` API provides read and write access to the query of a`URL`. The `URLSearchParams` class can also be used standalone with one of the
|
|
746
|
+
* The `URLSearchParams` API provides read and write access to the query of a `URL`. The `URLSearchParams` class can also be used standalone with one of the
|
|
730
747
|
* four following constructors.
|
|
731
748
|
* The `URLSearchParams` class is also available on the global object.
|
|
732
749
|
*
|
|
@@ -784,14 +801,14 @@ declare module "url" {
|
|
|
784
801
|
append(name: string, value: string): void;
|
|
785
802
|
/**
|
|
786
803
|
* If `value` is provided, removes all name-value pairs
|
|
787
|
-
* where name is `name` and value is `value
|
|
804
|
+
* where name is `name` and value is `value`.
|
|
788
805
|
*
|
|
789
806
|
* If `value` is not provided, removes all name-value pairs whose name is `name`.
|
|
790
807
|
*/
|
|
791
808
|
delete(name: string, value?: string): void;
|
|
792
809
|
/**
|
|
793
810
|
* Returns an ES6 `Iterator` over each of the name-value pairs in the query.
|
|
794
|
-
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array`is the `name`, the second item of the `Array` is the `value`.
|
|
811
|
+
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array` is the `name`, the second item of the `Array` is the `value`.
|
|
795
812
|
*
|
|
796
813
|
* Alias for `urlSearchParams[@@iterator]()`.
|
|
797
814
|
*/
|
|
@@ -812,7 +829,7 @@ declare module "url" {
|
|
|
812
829
|
* @param thisArg To be used as `this` value for when `fn` is called
|
|
813
830
|
*/
|
|
814
831
|
forEach<TThis = this>(
|
|
815
|
-
|
|
832
|
+
fn: (this: TThis, value: string, name: string, searchParams: URLSearchParams) => void,
|
|
816
833
|
thisArg?: TThis,
|
|
817
834
|
): void;
|
|
818
835
|
/**
|
|
@@ -827,7 +844,7 @@ declare module "url" {
|
|
|
827
844
|
*/
|
|
828
845
|
getAll(name: string): string[];
|
|
829
846
|
/**
|
|
830
|
-
* Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument.
|
|
847
|
+
* Checks if the `URLSearchParams` object contains key-value pair(s) based on `name` and an optional `value` argument.
|
|
831
848
|
*
|
|
832
849
|
* If `value` is provided, returns `true` when name-value pair with
|
|
833
850
|
* same `name` and `value` exists.
|
node v18.19/v8.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `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:
|
|
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
|
-
* const v8 = require('v8');
|
|
5
|
+
* const v8 = require('node:v8');
|
|
6
6
|
* ```
|
|
7
|
-
* @see [source](https://github.com/nodejs/node/blob/v18.
|
|
7
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.19.0/lib/v8.js)
|
|
8
8
|
*/
|
|
9
9
|
declare module "v8" {
|
|
10
10
|
import { Readable } from "node:stream";
|
|
@@ -29,6 +29,9 @@ declare module "v8" {
|
|
|
29
29
|
does_zap_garbage: DoesZapCodeSpaceFlag;
|
|
30
30
|
number_of_native_contexts: number;
|
|
31
31
|
number_of_detached_contexts: number;
|
|
32
|
+
total_global_handles_size: number;
|
|
33
|
+
used_global_handles_size: number;
|
|
34
|
+
external_memory: number;
|
|
32
35
|
}
|
|
33
36
|
interface HeapCodeStatistics {
|
|
34
37
|
code_and_metadata_size: number;
|
|
@@ -68,6 +71,15 @@ declare module "v8" {
|
|
|
68
71
|
* of contexts that were detached and not yet garbage collected. This number
|
|
69
72
|
* being non-zero indicates a potential memory leak.
|
|
70
73
|
*
|
|
74
|
+
* `total_global_handles_size` The value of total\_global\_handles\_size is the
|
|
75
|
+
* total memory size of V8 global handles.
|
|
76
|
+
*
|
|
77
|
+
* `used_global_handles_size` The value of used\_global\_handles\_size is the
|
|
78
|
+
* used memory size of V8 global handles.
|
|
79
|
+
*
|
|
80
|
+
* `external_memory` The value of external\_memory is the memory size of array
|
|
81
|
+
* buffers and external strings.
|
|
82
|
+
*
|
|
71
83
|
* ```js
|
|
72
84
|
* {
|
|
73
85
|
* total_heap_size: 7326976,
|
|
@@ -80,7 +92,10 @@ declare module "v8" {
|
|
|
80
92
|
* peak_malloced_memory: 1127496,
|
|
81
93
|
* does_zap_garbage: 0,
|
|
82
94
|
* number_of_native_contexts: 1,
|
|
83
|
-
* number_of_detached_contexts: 0
|
|
95
|
+
* number_of_detached_contexts: 0,
|
|
96
|
+
* total_global_handles_size: 8192,
|
|
97
|
+
* used_global_handles_size: 3296,
|
|
98
|
+
* external_memory: 318824
|
|
84
99
|
* }
|
|
85
100
|
* ```
|
|
86
101
|
* @since v1.0.0
|
|
@@ -90,7 +105,7 @@ declare module "v8" {
|
|
|
90
105
|
* Returns statistics about the V8 heap spaces, i.e. the segments which make up
|
|
91
106
|
* the V8 heap. Neither the ordering of heap spaces, nor the availability of a
|
|
92
107
|
* heap space can be guaranteed as the statistics are provided via the
|
|
93
|
-
* V8[`GetHeapSpaceStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4) function and may change from one V8 version to the
|
|
108
|
+
* V8 [`GetHeapSpaceStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4) function and may change from one V8 version to the
|
|
94
109
|
* next.
|
|
95
110
|
*
|
|
96
111
|
* The value returned is an array of objects containing the following properties:
|
|
@@ -149,7 +164,7 @@ declare module "v8" {
|
|
|
149
164
|
*
|
|
150
165
|
* ```js
|
|
151
166
|
* // Print GC events to stdout for one minute.
|
|
152
|
-
* const v8 = require('v8');
|
|
167
|
+
* const v8 = require('node:v8');
|
|
153
168
|
* v8.setFlagsFromString('--trace_gc');
|
|
154
169
|
* setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
|
|
155
170
|
* ```
|
|
@@ -172,7 +187,7 @@ declare module "v8" {
|
|
|
172
187
|
*
|
|
173
188
|
* ```js
|
|
174
189
|
* // Print heap snapshot to the console
|
|
175
|
-
* const v8 = require('v8');
|
|
190
|
+
* const v8 = require('node:v8');
|
|
176
191
|
* const stream = v8.getHeapSnapshot();
|
|
177
192
|
* stream.pipe(process.stdout);
|
|
178
193
|
* ```
|
|
@@ -197,12 +212,12 @@ declare module "v8" {
|
|
|
197
212
|
* for a duration depending on the heap size.
|
|
198
213
|
*
|
|
199
214
|
* ```js
|
|
200
|
-
* const { writeHeapSnapshot } = require('v8');
|
|
215
|
+
* const { writeHeapSnapshot } = require('node:v8');
|
|
201
216
|
* const {
|
|
202
217
|
* Worker,
|
|
203
218
|
* isMainThread,
|
|
204
|
-
* parentPort
|
|
205
|
-
* } = require('worker_threads');
|
|
219
|
+
* parentPort,
|
|
220
|
+
* } = require('node:worker_threads');
|
|
206
221
|
*
|
|
207
222
|
* if (isMainThread) {
|
|
208
223
|
* const worker = new Worker(__filename);
|
|
@@ -233,13 +248,16 @@ declare module "v8" {
|
|
|
233
248
|
*/
|
|
234
249
|
function writeHeapSnapshot(filename?: string): string;
|
|
235
250
|
/**
|
|
236
|
-
*
|
|
251
|
+
* Get statistics about code and its metadata in the heap, see
|
|
252
|
+
* V8 [`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the
|
|
253
|
+
* following properties:
|
|
237
254
|
*
|
|
238
255
|
* ```js
|
|
239
256
|
* {
|
|
240
257
|
* code_and_metadata_size: 212208,
|
|
241
258
|
* bytecode_and_metadata_size: 161368,
|
|
242
|
-
* external_script_source_size: 1410794
|
|
259
|
+
* external_script_source_size: 1410794,
|
|
260
|
+
* cpu_profiler_metadata_size: 0,
|
|
243
261
|
* }
|
|
244
262
|
* ```
|
|
245
263
|
* @since v12.8.0
|
|
@@ -289,7 +307,7 @@ declare module "v8" {
|
|
|
289
307
|
*/
|
|
290
308
|
writeDouble(value: number): void;
|
|
291
309
|
/**
|
|
292
|
-
* Write raw bytes into the serializer
|
|
310
|
+
* Write raw bytes into the serializer's internal buffer. The deserializer
|
|
293
311
|
* will require a way to compute the length of the buffer.
|
|
294
312
|
* For use inside of a custom `serializer._writeHostObject()`.
|
|
295
313
|
*/
|
|
@@ -345,7 +363,7 @@ declare module "v8" {
|
|
|
345
363
|
*/
|
|
346
364
|
readDouble(): number;
|
|
347
365
|
/**
|
|
348
|
-
* Read raw bytes from the deserializer
|
|
366
|
+
* Read raw bytes from the deserializer's internal buffer. The `length` parameter
|
|
349
367
|
* must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`.
|
|
350
368
|
* For use inside of a custom `deserializer._readHostObject()`.
|
|
351
369
|
*/
|
|
@@ -390,17 +408,100 @@ declare module "v8" {
|
|
|
390
408
|
* @since v15.1.0, v14.18.0, v12.22.0
|
|
391
409
|
*/
|
|
392
410
|
function stopCoverage(): void;
|
|
393
|
-
|
|
411
|
+
/**
|
|
412
|
+
* The API is a no-op if `--heapsnapshot-near-heap-limit` is already set from the command line or the API is called more than once.
|
|
413
|
+
* `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-v18.x/api/cli.html#--heapsnapshot-near-heap-limitmax_count) for more information.
|
|
414
|
+
* @experimental
|
|
415
|
+
* @since v18.10.0, v16.18.0
|
|
416
|
+
*/
|
|
417
|
+
function setHeapSnapshotNearHeapLimit(limit: number): void;
|
|
394
418
|
/**
|
|
395
419
|
* This API collects GC data in current thread.
|
|
420
|
+
* @since v18.15.0
|
|
396
421
|
*/
|
|
397
422
|
class GCProfiler {
|
|
398
423
|
/**
|
|
399
424
|
* Start collecting GC data.
|
|
425
|
+
* @since v18.15.0
|
|
400
426
|
*/
|
|
401
427
|
start(): void;
|
|
402
428
|
/**
|
|
403
|
-
* Stop collecting GC data and return
|
|
429
|
+
* Stop collecting GC data and return an object.The content of object
|
|
430
|
+
* is as follows.
|
|
431
|
+
*
|
|
432
|
+
* ```json
|
|
433
|
+
* {
|
|
434
|
+
* "version": 1,
|
|
435
|
+
* "startTime": 1674059033862,
|
|
436
|
+
* "statistics": [
|
|
437
|
+
* {
|
|
438
|
+
* "gcType": "Scavenge",
|
|
439
|
+
* "beforeGC": {
|
|
440
|
+
* "heapStatistics": {
|
|
441
|
+
* "totalHeapSize": 5005312,
|
|
442
|
+
* "totalHeapSizeExecutable": 524288,
|
|
443
|
+
* "totalPhysicalSize": 5226496,
|
|
444
|
+
* "totalAvailableSize": 4341325216,
|
|
445
|
+
* "totalGlobalHandlesSize": 8192,
|
|
446
|
+
* "usedGlobalHandlesSize": 2112,
|
|
447
|
+
* "usedHeapSize": 4883840,
|
|
448
|
+
* "heapSizeLimit": 4345298944,
|
|
449
|
+
* "mallocedMemory": 254128,
|
|
450
|
+
* "externalMemory": 225138,
|
|
451
|
+
* "peakMallocedMemory": 181760
|
|
452
|
+
* },
|
|
453
|
+
* "heapSpaceStatistics": [
|
|
454
|
+
* {
|
|
455
|
+
* "spaceName": "read_only_space",
|
|
456
|
+
* "spaceSize": 0,
|
|
457
|
+
* "spaceUsedSize": 0,
|
|
458
|
+
* "spaceAvailableSize": 0,
|
|
459
|
+
* "physicalSpaceSize": 0
|
|
460
|
+
* }
|
|
461
|
+
* ]
|
|
462
|
+
* },
|
|
463
|
+
* "cost": 1574.14,
|
|
464
|
+
* "afterGC": {
|
|
465
|
+
* "heapStatistics": {
|
|
466
|
+
* "totalHeapSize": 6053888,
|
|
467
|
+
* "totalHeapSizeExecutable": 524288,
|
|
468
|
+
* "totalPhysicalSize": 5500928,
|
|
469
|
+
* "totalAvailableSize": 4341101384,
|
|
470
|
+
* "totalGlobalHandlesSize": 8192,
|
|
471
|
+
* "usedGlobalHandlesSize": 2112,
|
|
472
|
+
* "usedHeapSize": 4059096,
|
|
473
|
+
* "heapSizeLimit": 4345298944,
|
|
474
|
+
* "mallocedMemory": 254128,
|
|
475
|
+
* "externalMemory": 225138,
|
|
476
|
+
* "peakMallocedMemory": 181760
|
|
477
|
+
* },
|
|
478
|
+
* "heapSpaceStatistics": [
|
|
479
|
+
* {
|
|
480
|
+
* "spaceName": "read_only_space",
|
|
481
|
+
* "spaceSize": 0,
|
|
482
|
+
* "spaceUsedSize": 0,
|
|
483
|
+
* "spaceAvailableSize": 0,
|
|
484
|
+
* "physicalSpaceSize": 0
|
|
485
|
+
* }
|
|
486
|
+
* ]
|
|
487
|
+
* }
|
|
488
|
+
* }
|
|
489
|
+
* ],
|
|
490
|
+
* "endTime": 1674059036865
|
|
491
|
+
* }
|
|
492
|
+
* ```
|
|
493
|
+
*
|
|
494
|
+
* Here's an example.
|
|
495
|
+
*
|
|
496
|
+
* ```js
|
|
497
|
+
* const { GCProfiler } = require('v8');
|
|
498
|
+
* const profiler = new GCProfiler();
|
|
499
|
+
* profiler.start();
|
|
500
|
+
* setTimeout(() => {
|
|
501
|
+
* console.log(profiler.stop());
|
|
502
|
+
* }, 1000);
|
|
503
|
+
* ```
|
|
504
|
+
* @since v18.15.0
|
|
404
505
|
*/
|
|
405
506
|
stop(): GCProfilerResult;
|
|
406
507
|
}
|
|
@@ -535,6 +636,117 @@ declare module "v8" {
|
|
|
535
636
|
* @since v17.1.0, v16.14.0
|
|
536
637
|
*/
|
|
537
638
|
const promiseHooks: PromiseHooks;
|
|
639
|
+
type StartupSnapshotCallbackFn = (args: any) => any;
|
|
640
|
+
interface StartupSnapshot {
|
|
641
|
+
/**
|
|
642
|
+
* Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
|
|
643
|
+
* This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.
|
|
644
|
+
* @since v18.6.0, v16.17.0
|
|
645
|
+
*/
|
|
646
|
+
addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
647
|
+
/**
|
|
648
|
+
* Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
|
|
649
|
+
* The `callback` and the `data` (if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or
|
|
650
|
+
* to re-acquire resources that the application needs when the application is restarted from the snapshot.
|
|
651
|
+
* @since v18.6.0, v16.17.0
|
|
652
|
+
*/
|
|
653
|
+
addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
654
|
+
/**
|
|
655
|
+
* This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script.
|
|
656
|
+
* If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized
|
|
657
|
+
* data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
|
|
658
|
+
* @since v18.6.0, v16.17.0
|
|
659
|
+
*/
|
|
660
|
+
setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
661
|
+
/**
|
|
662
|
+
* Returns true if the Node.js instance is run to build a snapshot.
|
|
663
|
+
* @since v18.6.0, v16.17.0
|
|
664
|
+
*/
|
|
665
|
+
isBuildingSnapshot(): boolean;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* The `v8.startupSnapshot` interface can be used to add serialization and deserialization hooks for custom startup snapshots.
|
|
669
|
+
*
|
|
670
|
+
* ```bash
|
|
671
|
+
* $ node --snapshot-blob snapshot.blob --build-snapshot entry.js
|
|
672
|
+
* # This launches a process with the snapshot
|
|
673
|
+
* $ node --snapshot-blob snapshot.blob
|
|
674
|
+
* ```
|
|
675
|
+
*
|
|
676
|
+
* In the example above, `entry.js` can use methods from the `v8.startupSnapshot` interface to specify how to save information for custom objects
|
|
677
|
+
* in the snapshot during serialization
|
|
678
|
+
* and how the information can be used to synchronize these objects during deserialization of the snapshot.
|
|
679
|
+
* For example, if the `entry.js` contains the following script:
|
|
680
|
+
*
|
|
681
|
+
* ```js
|
|
682
|
+
* 'use strict';
|
|
683
|
+
*
|
|
684
|
+
* const fs = require('node:fs');
|
|
685
|
+
* const zlib = require('node:zlib');
|
|
686
|
+
* const path = require('node:path');
|
|
687
|
+
* const assert = require('node:assert');
|
|
688
|
+
*
|
|
689
|
+
* const v8 = require('node:v8');
|
|
690
|
+
*
|
|
691
|
+
* class BookShelf {
|
|
692
|
+
* storage = new Map();
|
|
693
|
+
*
|
|
694
|
+
* // Reading a series of files from directory and store them into storage.
|
|
695
|
+
* constructor(directory, books) {
|
|
696
|
+
* for (const book of books) {
|
|
697
|
+
* this.storage.set(book, fs.readFileSync(path.join(directory, book)));
|
|
698
|
+
* }
|
|
699
|
+
* }
|
|
700
|
+
*
|
|
701
|
+
* static compressAll(shelf) {
|
|
702
|
+
* for (const [ book, content ] of shelf.storage) {
|
|
703
|
+
* shelf.storage.set(book, zlib.gzipSync(content));
|
|
704
|
+
* }
|
|
705
|
+
* }
|
|
706
|
+
*
|
|
707
|
+
* static decompressAll(shelf) {
|
|
708
|
+
* for (const [ book, content ] of shelf.storage) {
|
|
709
|
+
* shelf.storage.set(book, zlib.gunzipSync(content));
|
|
710
|
+
* }
|
|
711
|
+
* }
|
|
712
|
+
* }
|
|
713
|
+
*
|
|
714
|
+
* // __dirname here is where the snapshot script is placed
|
|
715
|
+
* // during snapshot building time.
|
|
716
|
+
* const shelf = new BookShelf(__dirname, [
|
|
717
|
+
* 'book1.en_US.txt',
|
|
718
|
+
* 'book1.es_ES.txt',
|
|
719
|
+
* 'book2.zh_CN.txt',
|
|
720
|
+
* ]);
|
|
721
|
+
*
|
|
722
|
+
* assert(v8.startupSnapshot.isBuildingSnapshot());
|
|
723
|
+
* // On snapshot serialization, compress the books to reduce size.
|
|
724
|
+
* v8.startupSnapshot.addSerializeCallback(BookShelf.compressAll, shelf);
|
|
725
|
+
* // On snapshot deserialization, decompress the books.
|
|
726
|
+
* v8.startupSnapshot.addDeserializeCallback(BookShelf.decompressAll, shelf);
|
|
727
|
+
* v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
|
|
728
|
+
* // process.env and process.argv are refreshed during snapshot
|
|
729
|
+
* // deserialization.
|
|
730
|
+
* const lang = process.env.BOOK_LANG || 'en_US';
|
|
731
|
+
* const book = process.argv[1];
|
|
732
|
+
* const name = `${book}.${lang}.txt`;
|
|
733
|
+
* console.log(shelf.storage.get(name));
|
|
734
|
+
* }, shelf);
|
|
735
|
+
* ```
|
|
736
|
+
*
|
|
737
|
+
* The resulted binary will get print the data deserialized from the snapshot during start up, using the refreshed `process.env` and `process.argv` of the launched process:
|
|
738
|
+
*
|
|
739
|
+
* ```bash
|
|
740
|
+
* $ BOOK_LANG=es_ES node --snapshot-blob snapshot.blob book1
|
|
741
|
+
* # Prints content of book1.es_ES.txt deserialized from the snapshot.
|
|
742
|
+
* ```
|
|
743
|
+
*
|
|
744
|
+
* Currently the application deserialized from a user-land snapshot cannot be snapshotted again, so these APIs are only available to applications that are not deserialized from a user-land snapshot.
|
|
745
|
+
*
|
|
746
|
+
* @experimental
|
|
747
|
+
* @since v18.6.0, v16.17.0
|
|
748
|
+
*/
|
|
749
|
+
const startupSnapshot: StartupSnapshot;
|
|
538
750
|
}
|
|
539
751
|
declare module "node:v8" {
|
|
540
752
|
export * from "v8";
|