@types/node 20.11.16 → 20.11.18
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/package.json +2 -2
- node/ts4.8/url.d.ts +59 -42
- node/ts4.8/v8.d.ts +134 -5
- node/url.d.ts +59 -42
- node/v8.d.ts +134 -5
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: 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "20.11.
|
|
3
|
+
"version": "20.11.18",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -224,6 +224,6 @@
|
|
|
224
224
|
"dependencies": {
|
|
225
225
|
"undici-types": "~5.26.4"
|
|
226
226
|
},
|
|
227
|
-
"typesPublisherContentHash": "
|
|
227
|
+
"typesPublisherContentHash": "ebbb1659628d08ed4cd9663790fc53fdf85f7c7e2eb5d733010a94b3c7104873",
|
|
228
228
|
"typeScriptVersion": "4.6"
|
|
229
229
|
}
|
node/ts4.8/url.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ```js
|
|
6
6
|
* import url from 'node:url';
|
|
7
7
|
* ```
|
|
8
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
8
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.11.0/lib/url.js)
|
|
9
9
|
*/
|
|
10
10
|
declare module "url" {
|
|
11
11
|
import { Blob as NodeBlob } from "node:buffer";
|
|
@@ -74,7 +74,7 @@ declare module "url" {
|
|
|
74
74
|
function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
|
|
75
75
|
function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
|
|
76
76
|
/**
|
|
77
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
77
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
78
78
|
*
|
|
79
79
|
* ```js
|
|
80
80
|
* const url = require('node:url');
|
|
@@ -100,33 +100,33 @@ declare module "url" {
|
|
|
100
100
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
101
101
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
102
102
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
103
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
103
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
104
104
|
* * `urlObject.slashes` property is true;
|
|
105
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
106
|
-
* * 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
|
|
107
|
-
* and appended to `result`followed by the literal string `@`.
|
|
105
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
106
|
+
* * 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
|
|
107
|
+
* and appended to `result` followed by the literal string `@`.
|
|
108
108
|
* * If the `urlObject.host` property is `undefined` then:
|
|
109
109
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
110
110
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
111
111
|
* an `Error` is thrown.
|
|
112
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
112
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
113
113
|
* * The literal string `:` is appended to `result`, and
|
|
114
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
115
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
114
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
115
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
116
116
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
117
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
117
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
118
118
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
119
119
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
120
120
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
121
|
-
* * 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
|
|
122
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
121
|
+
* * 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
|
|
122
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
123
123
|
* * Otherwise, if `urlObject.search` is a string:
|
|
124
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
124
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
125
125
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
126
126
|
* * The value of `urlObject.search` is appended to `result`.
|
|
127
127
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
128
128
|
* * If the `urlObject.hash` property is a string:
|
|
129
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
129
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
130
130
|
* character, the literal string `#` is appended to `result`.
|
|
131
131
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
132
132
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -138,18 +138,18 @@ declare module "url" {
|
|
|
138
138
|
*/
|
|
139
139
|
function format(urlObject: URL, options?: URLFormatOptions): string;
|
|
140
140
|
/**
|
|
141
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
141
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
142
142
|
*
|
|
143
143
|
* ```js
|
|
144
|
-
* const url = require('url');
|
|
144
|
+
* const url = require('node:url');
|
|
145
145
|
* url.format({
|
|
146
146
|
* protocol: 'https',
|
|
147
147
|
* hostname: 'example.com',
|
|
148
148
|
* pathname: '/some/path',
|
|
149
149
|
* query: {
|
|
150
150
|
* page: 1,
|
|
151
|
-
* format: 'json'
|
|
152
|
-
* }
|
|
151
|
+
* format: 'json',
|
|
152
|
+
* },
|
|
153
153
|
* });
|
|
154
154
|
*
|
|
155
155
|
* // => 'https://example.com/some/path?page=1&format=json'
|
|
@@ -164,33 +164,33 @@ declare module "url" {
|
|
|
164
164
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
165
165
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
166
166
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
167
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
167
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
168
168
|
* * `urlObject.slashes` property is true;
|
|
169
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
170
|
-
* * 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
|
|
171
|
-
* and appended to `result`followed by the literal string `@`.
|
|
169
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
170
|
+
* * 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
|
|
171
|
+
* and appended to `result` followed by the literal string `@`.
|
|
172
172
|
* * If the `urlObject.host` property is `undefined` then:
|
|
173
173
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
174
174
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
175
175
|
* an `Error` is thrown.
|
|
176
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
176
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
177
177
|
* * The literal string `:` is appended to `result`, and
|
|
178
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
179
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
178
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
179
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
180
180
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
181
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
181
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
182
182
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
183
183
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
184
184
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
185
|
-
* * 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
|
|
186
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
185
|
+
* * 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
|
|
186
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
187
187
|
* * Otherwise, if `urlObject.search` is a string:
|
|
188
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
188
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
189
189
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
190
190
|
* * The value of `urlObject.search` is appended to `result`.
|
|
191
191
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
192
192
|
* * If the `urlObject.hash` property is a string:
|
|
193
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
193
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
194
194
|
* character, the literal string `#` is appended to `result`.
|
|
195
195
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
196
196
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -345,9 +345,26 @@ declare module "url" {
|
|
|
345
345
|
*/
|
|
346
346
|
function urlToHttpOptions(url: URL): ClientRequestArgs;
|
|
347
347
|
interface URLFormatOptions {
|
|
348
|
+
/**
|
|
349
|
+
* `true` if the serialized URL string should include the username and password, `false` otherwise.
|
|
350
|
+
* @default true
|
|
351
|
+
*/
|
|
348
352
|
auth?: boolean | undefined;
|
|
353
|
+
/**
|
|
354
|
+
* `true` if the serialized URL string should include the fragment, `false` otherwise.
|
|
355
|
+
* @default true
|
|
356
|
+
*/
|
|
349
357
|
fragment?: boolean | undefined;
|
|
358
|
+
/**
|
|
359
|
+
* `true` if the serialized URL string should include the search query, `false` otherwise.
|
|
360
|
+
* @default true
|
|
361
|
+
*/
|
|
350
362
|
search?: boolean | undefined;
|
|
363
|
+
/**
|
|
364
|
+
* `true` if Unicode characters appearing in the host component of the URL string should be encoded directly as opposed to
|
|
365
|
+
* being Punycode encoded.
|
|
366
|
+
* @default false
|
|
367
|
+
*/
|
|
351
368
|
unicode?: boolean | undefined;
|
|
352
369
|
}
|
|
353
370
|
/**
|
|
@@ -357,7 +374,7 @@ declare module "url" {
|
|
|
357
374
|
*
|
|
358
375
|
* In accordance with browser conventions, all properties of `URL` objects
|
|
359
376
|
* are implemented as getters and setters on the class prototype, rather than as
|
|
360
|
-
* data properties on the object itself. Thus, unlike `legacy urlObject`
|
|
377
|
+
* data properties on the object itself. Thus, unlike `legacy urlObject`s,
|
|
361
378
|
* 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
|
|
362
379
|
* return `true`.
|
|
363
380
|
* @since v7.0.0, v6.13.0
|
|
@@ -381,7 +398,7 @@ declare module "url" {
|
|
|
381
398
|
* console.log(otherBlob.size);
|
|
382
399
|
* ```
|
|
383
400
|
*
|
|
384
|
-
* The data stored by the registered `Blob` will be retained in memory until`URL.revokeObjectURL()` is called to remove it.
|
|
401
|
+
* The data stored by the registered `Blob` will be retained in memory until `URL.revokeObjectURL()` is called to remove it.
|
|
385
402
|
*
|
|
386
403
|
* `Blob` objects are registered within the current thread. If using Worker
|
|
387
404
|
* Threads, `Blob` objects registered within one Worker will not be available
|
|
@@ -397,7 +414,7 @@ declare module "url" {
|
|
|
397
414
|
* @experimental
|
|
398
415
|
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
|
399
416
|
*/
|
|
400
|
-
static revokeObjectURL(
|
|
417
|
+
static revokeObjectURL(id: string): void;
|
|
401
418
|
/**
|
|
402
419
|
* Checks if an `input` relative to the `base` can be parsed to a `URL`.
|
|
403
420
|
*
|
|
@@ -412,7 +429,7 @@ declare module "url" {
|
|
|
412
429
|
* @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.
|
|
413
430
|
*/
|
|
414
431
|
static canParse(input: string, base?: string): boolean;
|
|
415
|
-
constructor(input: string, base?: string | URL);
|
|
432
|
+
constructor(input: string | { toString: () => string }, base?: string | URL);
|
|
416
433
|
/**
|
|
417
434
|
* Gets and sets the fragment portion of the URL.
|
|
418
435
|
*
|
|
@@ -541,14 +558,14 @@ declare module "url" {
|
|
|
541
558
|
* // Prints https://example.org/abcdef?123
|
|
542
559
|
* ```
|
|
543
560
|
*
|
|
544
|
-
* Invalid URL characters included in the value assigned to the `pathname`property are `percent-encoded`. The selection of which characters
|
|
561
|
+
* Invalid URL characters included in the value assigned to the `pathname` property are `percent-encoded`. The selection of which characters
|
|
545
562
|
* to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
546
563
|
*/
|
|
547
564
|
pathname: string;
|
|
548
565
|
/**
|
|
549
566
|
* Gets and sets the port portion of the URL.
|
|
550
567
|
*
|
|
551
|
-
* 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
|
|
568
|
+
* 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
|
|
552
569
|
* result in the `port` value becoming
|
|
553
570
|
* the empty string (`''`).
|
|
554
571
|
*
|
|
@@ -688,7 +705,7 @@ declare module "url" {
|
|
|
688
705
|
* // Prints https://123:xyz@example.com/
|
|
689
706
|
* ```
|
|
690
707
|
*
|
|
691
|
-
* Any invalid URL characters appearing in the value assigned the `username`property will be `percent-encoded`. The selection of which
|
|
708
|
+
* Any invalid URL characters appearing in the value assigned the `username` property will be `percent-encoded`. The selection of which
|
|
692
709
|
* characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
693
710
|
*/
|
|
694
711
|
username: string;
|
|
@@ -716,7 +733,7 @@ declare module "url" {
|
|
|
716
733
|
toJSON(): string;
|
|
717
734
|
}
|
|
718
735
|
/**
|
|
719
|
-
* 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
|
|
736
|
+
* 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
|
|
720
737
|
* four following constructors.
|
|
721
738
|
* The `URLSearchParams` class is also available on the global object.
|
|
722
739
|
*
|
|
@@ -774,14 +791,14 @@ declare module "url" {
|
|
|
774
791
|
append(name: string, value: string): void;
|
|
775
792
|
/**
|
|
776
793
|
* If `value` is provided, removes all name-value pairs
|
|
777
|
-
* where name is `name` and value is `value
|
|
794
|
+
* where name is `name` and value is `value`.
|
|
778
795
|
*
|
|
779
796
|
* If `value` is not provided, removes all name-value pairs whose name is `name`.
|
|
780
797
|
*/
|
|
781
798
|
delete(name: string, value?: string): void;
|
|
782
799
|
/**
|
|
783
800
|
* Returns an ES6 `Iterator` over each of the name-value pairs in the query.
|
|
784
|
-
* 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`.
|
|
801
|
+
* 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`.
|
|
785
802
|
*
|
|
786
803
|
* Alias for `urlSearchParams[@@iterator]()`.
|
|
787
804
|
*/
|
|
@@ -802,7 +819,7 @@ declare module "url" {
|
|
|
802
819
|
* @param thisArg To be used as `this` value for when `fn` is called
|
|
803
820
|
*/
|
|
804
821
|
forEach<TThis = this>(
|
|
805
|
-
|
|
822
|
+
fn: (this: TThis, value: string, name: string, searchParams: URLSearchParams) => void,
|
|
806
823
|
thisArg?: TThis,
|
|
807
824
|
): void;
|
|
808
825
|
/**
|
|
@@ -817,7 +834,7 @@ declare module "url" {
|
|
|
817
834
|
*/
|
|
818
835
|
getAll(name: string): string[];
|
|
819
836
|
/**
|
|
820
|
-
* Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument.
|
|
837
|
+
* Checks if the `URLSearchParams` object contains key-value pair(s) based on `name` and an optional `value` argument.
|
|
821
838
|
*
|
|
822
839
|
* If `value` is provided, returns `true` when name-value pair with
|
|
823
840
|
* same `name` and `value` exists.
|
node/ts4.8/v8.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* ```js
|
|
5
5
|
* const v8 = require('node:v8');
|
|
6
6
|
* ```
|
|
7
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
7
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.11.0/lib/v8.js)
|
|
8
8
|
*/
|
|
9
9
|
declare module "v8" {
|
|
10
10
|
import { Readable } from "node:stream";
|
|
@@ -38,6 +38,18 @@ declare module "v8" {
|
|
|
38
38
|
bytecode_and_metadata_size: number;
|
|
39
39
|
external_script_source_size: number;
|
|
40
40
|
}
|
|
41
|
+
interface HeapSnapshotOptions {
|
|
42
|
+
/**
|
|
43
|
+
* If true, expose internals in the heap snapshot.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
exposeInternals?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* If true, expose numeric values in artificial fields.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
exposeNumericValues?: boolean;
|
|
52
|
+
}
|
|
41
53
|
/**
|
|
42
54
|
* Returns an integer representing a version tag derived from the V8 version,
|
|
43
55
|
* command-line flags, and detected CPU features. This is useful for determining
|
|
@@ -105,7 +117,7 @@ declare module "v8" {
|
|
|
105
117
|
* Returns statistics about the V8 heap spaces, i.e. the segments which make up
|
|
106
118
|
* the V8 heap. Neither the ordering of heap spaces, nor the availability of a
|
|
107
119
|
* heap space can be guaranteed as the statistics are provided via 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
|
|
120
|
+
* 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
|
|
109
121
|
* next.
|
|
110
122
|
*
|
|
111
123
|
* The value returned is an array of objects containing the following properties:
|
|
@@ -194,7 +206,7 @@ declare module "v8" {
|
|
|
194
206
|
* @since v11.13.0
|
|
195
207
|
* @return A Readable containing the V8 heap snapshot.
|
|
196
208
|
*/
|
|
197
|
-
function getHeapSnapshot(): Readable;
|
|
209
|
+
function getHeapSnapshot(options?: HeapSnapshotOptions): Readable;
|
|
198
210
|
/**
|
|
199
211
|
* Generates a snapshot of the current V8 heap and writes it to a JSON
|
|
200
212
|
* file. This file is intended to be used with tools such as Chrome
|
|
@@ -246,10 +258,10 @@ declare module "v8" {
|
|
|
246
258
|
* worker thread.
|
|
247
259
|
* @return The filename where the snapshot was saved.
|
|
248
260
|
*/
|
|
249
|
-
function writeHeapSnapshot(filename?: string): string;
|
|
261
|
+
function writeHeapSnapshot(filename?: string, options?: HeapSnapshotOptions): string;
|
|
250
262
|
/**
|
|
251
263
|
* 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
|
|
264
|
+
* V8 [`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the
|
|
253
265
|
* following properties:
|
|
254
266
|
*
|
|
255
267
|
* ```js
|
|
@@ -408,6 +420,13 @@ declare module "v8" {
|
|
|
408
420
|
* @since v15.1.0, v14.18.0, v12.22.0
|
|
409
421
|
*/
|
|
410
422
|
function stopCoverage(): void;
|
|
423
|
+
/**
|
|
424
|
+
* 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.
|
|
425
|
+
* `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--heapsnapshot-near-heap-limitmax_count) for more information.
|
|
426
|
+
* @experimental
|
|
427
|
+
* @since v18.10.0, v16.18.0
|
|
428
|
+
*/
|
|
429
|
+
function setHeapSnapshotNearHeapLimit(limit: number): void;
|
|
411
430
|
/**
|
|
412
431
|
* This API collects GC data in current thread.
|
|
413
432
|
* @since v19.6.0, v18.15.0
|
|
@@ -629,6 +648,116 @@ declare module "v8" {
|
|
|
629
648
|
* @since v17.1.0, v16.14.0
|
|
630
649
|
*/
|
|
631
650
|
const promiseHooks: PromiseHooks;
|
|
651
|
+
type StartupSnapshotCallbackFn = (args: any) => any;
|
|
652
|
+
interface StartupSnapshot {
|
|
653
|
+
/**
|
|
654
|
+
* Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
|
|
655
|
+
* 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.
|
|
656
|
+
* @since v18.6.0, v16.17.0
|
|
657
|
+
*/
|
|
658
|
+
addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
659
|
+
/**
|
|
660
|
+
* Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
|
|
661
|
+
* 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
|
|
662
|
+
* to re-acquire resources that the application needs when the application is restarted from the snapshot.
|
|
663
|
+
* @since v18.6.0, v16.17.0
|
|
664
|
+
*/
|
|
665
|
+
addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
666
|
+
/**
|
|
667
|
+
* 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.
|
|
668
|
+
* 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
|
|
669
|
+
* data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
|
|
670
|
+
* @since v18.6.0, v16.17.0
|
|
671
|
+
*/
|
|
672
|
+
setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
673
|
+
/**
|
|
674
|
+
* Returns true if the Node.js instance is run to build a snapshot.
|
|
675
|
+
* @since v18.6.0, v16.17.0
|
|
676
|
+
*/
|
|
677
|
+
isBuildingSnapshot(): boolean;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* The `v8.startupSnapshot` interface can be used to add serialization and deserialization hooks for custom startup snapshots.
|
|
681
|
+
*
|
|
682
|
+
* ```bash
|
|
683
|
+
* $ node --snapshot-blob snapshot.blob --build-snapshot entry.js
|
|
684
|
+
* # This launches a process with the snapshot
|
|
685
|
+
* $ node --snapshot-blob snapshot.blob
|
|
686
|
+
* ```
|
|
687
|
+
*
|
|
688
|
+
* In the example above, `entry.js` can use methods from the `v8.startupSnapshot` interface to specify how to save information for custom objects
|
|
689
|
+
* in the snapshot during serialization and how the information can be used to synchronize these objects during deserialization of the snapshot.
|
|
690
|
+
* For example, if the `entry.js` contains the following script:
|
|
691
|
+
*
|
|
692
|
+
* ```js
|
|
693
|
+
* 'use strict';
|
|
694
|
+
*
|
|
695
|
+
* const fs = require('node:fs');
|
|
696
|
+
* const zlib = require('node:zlib');
|
|
697
|
+
* const path = require('node:path');
|
|
698
|
+
* const assert = require('node:assert');
|
|
699
|
+
*
|
|
700
|
+
* const v8 = require('node:v8');
|
|
701
|
+
*
|
|
702
|
+
* class BookShelf {
|
|
703
|
+
* storage = new Map();
|
|
704
|
+
*
|
|
705
|
+
* // Reading a series of files from directory and store them into storage.
|
|
706
|
+
* constructor(directory, books) {
|
|
707
|
+
* for (const book of books) {
|
|
708
|
+
* this.storage.set(book, fs.readFileSync(path.join(directory, book)));
|
|
709
|
+
* }
|
|
710
|
+
* }
|
|
711
|
+
*
|
|
712
|
+
* static compressAll(shelf) {
|
|
713
|
+
* for (const [ book, content ] of shelf.storage) {
|
|
714
|
+
* shelf.storage.set(book, zlib.gzipSync(content));
|
|
715
|
+
* }
|
|
716
|
+
* }
|
|
717
|
+
*
|
|
718
|
+
* static decompressAll(shelf) {
|
|
719
|
+
* for (const [ book, content ] of shelf.storage) {
|
|
720
|
+
* shelf.storage.set(book, zlib.gunzipSync(content));
|
|
721
|
+
* }
|
|
722
|
+
* }
|
|
723
|
+
* }
|
|
724
|
+
*
|
|
725
|
+
* // __dirname here is where the snapshot script is placed
|
|
726
|
+
* // during snapshot building time.
|
|
727
|
+
* const shelf = new BookShelf(__dirname, [
|
|
728
|
+
* 'book1.en_US.txt',
|
|
729
|
+
* 'book1.es_ES.txt',
|
|
730
|
+
* 'book2.zh_CN.txt',
|
|
731
|
+
* ]);
|
|
732
|
+
*
|
|
733
|
+
* assert(v8.startupSnapshot.isBuildingSnapshot());
|
|
734
|
+
* // On snapshot serialization, compress the books to reduce size.
|
|
735
|
+
* v8.startupSnapshot.addSerializeCallback(BookShelf.compressAll, shelf);
|
|
736
|
+
* // On snapshot deserialization, decompress the books.
|
|
737
|
+
* v8.startupSnapshot.addDeserializeCallback(BookShelf.decompressAll, shelf);
|
|
738
|
+
* v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
|
|
739
|
+
* // process.env and process.argv are refreshed during snapshot
|
|
740
|
+
* // deserialization.
|
|
741
|
+
* const lang = process.env.BOOK_LANG || 'en_US';
|
|
742
|
+
* const book = process.argv[1];
|
|
743
|
+
* const name = `${book}.${lang}.txt`;
|
|
744
|
+
* console.log(shelf.storage.get(name));
|
|
745
|
+
* }, shelf);
|
|
746
|
+
* ```
|
|
747
|
+
*
|
|
748
|
+
* 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:
|
|
749
|
+
*
|
|
750
|
+
* ```bash
|
|
751
|
+
* $ BOOK_LANG=es_ES node --snapshot-blob snapshot.blob book1
|
|
752
|
+
* # Prints content of book1.es_ES.txt deserialized from the snapshot.
|
|
753
|
+
* ```
|
|
754
|
+
*
|
|
755
|
+
* 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.
|
|
756
|
+
*
|
|
757
|
+
* @experimental
|
|
758
|
+
* @since v18.6.0, v16.17.0
|
|
759
|
+
*/
|
|
760
|
+
const startupSnapshot: StartupSnapshot;
|
|
632
761
|
}
|
|
633
762
|
declare module "node:v8" {
|
|
634
763
|
export * from "v8";
|
node/url.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ```js
|
|
6
6
|
* import url from 'node:url';
|
|
7
7
|
* ```
|
|
8
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
8
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.11.0/lib/url.js)
|
|
9
9
|
*/
|
|
10
10
|
declare module "url" {
|
|
11
11
|
import { Blob as NodeBlob } from "node:buffer";
|
|
@@ -74,7 +74,7 @@ declare module "url" {
|
|
|
74
74
|
function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
|
|
75
75
|
function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
|
|
76
76
|
/**
|
|
77
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
77
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
78
78
|
*
|
|
79
79
|
* ```js
|
|
80
80
|
* const url = require('node:url');
|
|
@@ -100,33 +100,33 @@ declare module "url" {
|
|
|
100
100
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
101
101
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
102
102
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
103
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
103
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
104
104
|
* * `urlObject.slashes` property is true;
|
|
105
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
106
|
-
* * 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
|
|
107
|
-
* and appended to `result`followed by the literal string `@`.
|
|
105
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
106
|
+
* * 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
|
|
107
|
+
* and appended to `result` followed by the literal string `@`.
|
|
108
108
|
* * If the `urlObject.host` property is `undefined` then:
|
|
109
109
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
110
110
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
111
111
|
* an `Error` is thrown.
|
|
112
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
112
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
113
113
|
* * The literal string `:` is appended to `result`, and
|
|
114
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
115
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
114
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
115
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
116
116
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
117
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
117
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
118
118
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
119
119
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
120
120
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
121
|
-
* * 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
|
|
122
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
121
|
+
* * 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
|
|
122
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
123
123
|
* * Otherwise, if `urlObject.search` is a string:
|
|
124
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
124
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
125
125
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
126
126
|
* * The value of `urlObject.search` is appended to `result`.
|
|
127
127
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
128
128
|
* * If the `urlObject.hash` property is a string:
|
|
129
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
129
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
130
130
|
* character, the literal string `#` is appended to `result`.
|
|
131
131
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
132
132
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -138,18 +138,18 @@ declare module "url" {
|
|
|
138
138
|
*/
|
|
139
139
|
function format(urlObject: URL, options?: URLFormatOptions): string;
|
|
140
140
|
/**
|
|
141
|
-
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
141
|
+
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
142
142
|
*
|
|
143
143
|
* ```js
|
|
144
|
-
* const url = require('url');
|
|
144
|
+
* const url = require('node:url');
|
|
145
145
|
* url.format({
|
|
146
146
|
* protocol: 'https',
|
|
147
147
|
* hostname: 'example.com',
|
|
148
148
|
* pathname: '/some/path',
|
|
149
149
|
* query: {
|
|
150
150
|
* page: 1,
|
|
151
|
-
* format: 'json'
|
|
152
|
-
* }
|
|
151
|
+
* format: 'json',
|
|
152
|
+
* },
|
|
153
153
|
* });
|
|
154
154
|
*
|
|
155
155
|
* // => 'https://example.com/some/path?page=1&format=json'
|
|
@@ -164,33 +164,33 @@ declare module "url" {
|
|
|
164
164
|
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
165
165
|
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
166
166
|
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
167
|
-
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
167
|
+
* * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
|
|
168
168
|
* * `urlObject.slashes` property is true;
|
|
169
|
-
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
170
|
-
* * 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
|
|
171
|
-
* and appended to `result`followed by the literal string `@`.
|
|
169
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
|
|
170
|
+
* * 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
|
|
171
|
+
* and appended to `result` followed by the literal string `@`.
|
|
172
172
|
* * If the `urlObject.host` property is `undefined` then:
|
|
173
173
|
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
174
174
|
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
175
175
|
* an `Error` is thrown.
|
|
176
|
-
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
176
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
|
|
177
177
|
* * The literal string `:` is appended to `result`, and
|
|
178
|
-
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
179
|
-
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
178
|
+
* * The value of `urlObject.port` is coerced to a string and appended to `result`.
|
|
179
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
|
|
180
180
|
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
181
|
-
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
181
|
+
* * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
|
|
182
182
|
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
183
183
|
* * The value of `urlObject.pathname` is appended to `result`.
|
|
184
184
|
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
185
|
-
* * 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
|
|
186
|
-
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
185
|
+
* * 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
|
|
186
|
+
* `querystring` module's `stringify()` method passing the value of `urlObject.query`.
|
|
187
187
|
* * Otherwise, if `urlObject.search` is a string:
|
|
188
|
-
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
188
|
+
* * If the value of `urlObject.search` _does not start_ with the ASCII question
|
|
189
189
|
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
190
190
|
* * The value of `urlObject.search` is appended to `result`.
|
|
191
191
|
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
192
192
|
* * If the `urlObject.hash` property is a string:
|
|
193
|
-
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
193
|
+
* * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
|
|
194
194
|
* character, the literal string `#` is appended to `result`.
|
|
195
195
|
* * The value of `urlObject.hash` is appended to `result`.
|
|
196
196
|
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
@@ -345,9 +345,26 @@ declare module "url" {
|
|
|
345
345
|
*/
|
|
346
346
|
function urlToHttpOptions(url: URL): ClientRequestArgs;
|
|
347
347
|
interface URLFormatOptions {
|
|
348
|
+
/**
|
|
349
|
+
* `true` if the serialized URL string should include the username and password, `false` otherwise.
|
|
350
|
+
* @default true
|
|
351
|
+
*/
|
|
348
352
|
auth?: boolean | undefined;
|
|
353
|
+
/**
|
|
354
|
+
* `true` if the serialized URL string should include the fragment, `false` otherwise.
|
|
355
|
+
* @default true
|
|
356
|
+
*/
|
|
349
357
|
fragment?: boolean | undefined;
|
|
358
|
+
/**
|
|
359
|
+
* `true` if the serialized URL string should include the search query, `false` otherwise.
|
|
360
|
+
* @default true
|
|
361
|
+
*/
|
|
350
362
|
search?: boolean | undefined;
|
|
363
|
+
/**
|
|
364
|
+
* `true` if Unicode characters appearing in the host component of the URL string should be encoded directly as opposed to
|
|
365
|
+
* being Punycode encoded.
|
|
366
|
+
* @default false
|
|
367
|
+
*/
|
|
351
368
|
unicode?: boolean | undefined;
|
|
352
369
|
}
|
|
353
370
|
/**
|
|
@@ -357,7 +374,7 @@ declare module "url" {
|
|
|
357
374
|
*
|
|
358
375
|
* In accordance with browser conventions, all properties of `URL` objects
|
|
359
376
|
* are implemented as getters and setters on the class prototype, rather than as
|
|
360
|
-
* data properties on the object itself. Thus, unlike `legacy urlObject`
|
|
377
|
+
* data properties on the object itself. Thus, unlike `legacy urlObject`s,
|
|
361
378
|
* 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
|
|
362
379
|
* return `true`.
|
|
363
380
|
* @since v7.0.0, v6.13.0
|
|
@@ -381,7 +398,7 @@ declare module "url" {
|
|
|
381
398
|
* console.log(otherBlob.size);
|
|
382
399
|
* ```
|
|
383
400
|
*
|
|
384
|
-
* The data stored by the registered `Blob` will be retained in memory until`URL.revokeObjectURL()` is called to remove it.
|
|
401
|
+
* The data stored by the registered `Blob` will be retained in memory until `URL.revokeObjectURL()` is called to remove it.
|
|
385
402
|
*
|
|
386
403
|
* `Blob` objects are registered within the current thread. If using Worker
|
|
387
404
|
* Threads, `Blob` objects registered within one Worker will not be available
|
|
@@ -397,7 +414,7 @@ declare module "url" {
|
|
|
397
414
|
* @experimental
|
|
398
415
|
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
|
399
416
|
*/
|
|
400
|
-
static revokeObjectURL(
|
|
417
|
+
static revokeObjectURL(id: string): void;
|
|
401
418
|
/**
|
|
402
419
|
* Checks if an `input` relative to the `base` can be parsed to a `URL`.
|
|
403
420
|
*
|
|
@@ -412,7 +429,7 @@ declare module "url" {
|
|
|
412
429
|
* @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.
|
|
413
430
|
*/
|
|
414
431
|
static canParse(input: string, base?: string): boolean;
|
|
415
|
-
constructor(input: string, base?: string | URL);
|
|
432
|
+
constructor(input: string | { toString: () => string }, base?: string | URL);
|
|
416
433
|
/**
|
|
417
434
|
* Gets and sets the fragment portion of the URL.
|
|
418
435
|
*
|
|
@@ -541,14 +558,14 @@ declare module "url" {
|
|
|
541
558
|
* // Prints https://example.org/abcdef?123
|
|
542
559
|
* ```
|
|
543
560
|
*
|
|
544
|
-
* Invalid URL characters included in the value assigned to the `pathname`property are `percent-encoded`. The selection of which characters
|
|
561
|
+
* Invalid URL characters included in the value assigned to the `pathname` property are `percent-encoded`. The selection of which characters
|
|
545
562
|
* to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
546
563
|
*/
|
|
547
564
|
pathname: string;
|
|
548
565
|
/**
|
|
549
566
|
* Gets and sets the port portion of the URL.
|
|
550
567
|
*
|
|
551
|
-
* 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
|
|
568
|
+
* 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
|
|
552
569
|
* result in the `port` value becoming
|
|
553
570
|
* the empty string (`''`).
|
|
554
571
|
*
|
|
@@ -688,7 +705,7 @@ declare module "url" {
|
|
|
688
705
|
* // Prints https://123:xyz@example.com/
|
|
689
706
|
* ```
|
|
690
707
|
*
|
|
691
|
-
* Any invalid URL characters appearing in the value assigned the `username`property will be `percent-encoded`. The selection of which
|
|
708
|
+
* Any invalid URL characters appearing in the value assigned the `username` property will be `percent-encoded`. The selection of which
|
|
692
709
|
* characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
|
|
693
710
|
*/
|
|
694
711
|
username: string;
|
|
@@ -716,7 +733,7 @@ declare module "url" {
|
|
|
716
733
|
toJSON(): string;
|
|
717
734
|
}
|
|
718
735
|
/**
|
|
719
|
-
* 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
|
|
736
|
+
* 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
|
|
720
737
|
* four following constructors.
|
|
721
738
|
* The `URLSearchParams` class is also available on the global object.
|
|
722
739
|
*
|
|
@@ -774,14 +791,14 @@ declare module "url" {
|
|
|
774
791
|
append(name: string, value: string): void;
|
|
775
792
|
/**
|
|
776
793
|
* If `value` is provided, removes all name-value pairs
|
|
777
|
-
* where name is `name` and value is `value
|
|
794
|
+
* where name is `name` and value is `value`.
|
|
778
795
|
*
|
|
779
796
|
* If `value` is not provided, removes all name-value pairs whose name is `name`.
|
|
780
797
|
*/
|
|
781
798
|
delete(name: string, value?: string): void;
|
|
782
799
|
/**
|
|
783
800
|
* Returns an ES6 `Iterator` over each of the name-value pairs in the query.
|
|
784
|
-
* 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`.
|
|
801
|
+
* 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`.
|
|
785
802
|
*
|
|
786
803
|
* Alias for `urlSearchParams[@@iterator]()`.
|
|
787
804
|
*/
|
|
@@ -802,7 +819,7 @@ declare module "url" {
|
|
|
802
819
|
* @param thisArg To be used as `this` value for when `fn` is called
|
|
803
820
|
*/
|
|
804
821
|
forEach<TThis = this>(
|
|
805
|
-
|
|
822
|
+
fn: (this: TThis, value: string, name: string, searchParams: URLSearchParams) => void,
|
|
806
823
|
thisArg?: TThis,
|
|
807
824
|
): void;
|
|
808
825
|
/**
|
|
@@ -817,7 +834,7 @@ declare module "url" {
|
|
|
817
834
|
*/
|
|
818
835
|
getAll(name: string): string[];
|
|
819
836
|
/**
|
|
820
|
-
* Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument.
|
|
837
|
+
* Checks if the `URLSearchParams` object contains key-value pair(s) based on `name` and an optional `value` argument.
|
|
821
838
|
*
|
|
822
839
|
* If `value` is provided, returns `true` when name-value pair with
|
|
823
840
|
* same `name` and `value` exists.
|
node/v8.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* ```js
|
|
5
5
|
* const v8 = require('node:v8');
|
|
6
6
|
* ```
|
|
7
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
7
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.11.0/lib/v8.js)
|
|
8
8
|
*/
|
|
9
9
|
declare module "v8" {
|
|
10
10
|
import { Readable } from "node:stream";
|
|
@@ -38,6 +38,18 @@ declare module "v8" {
|
|
|
38
38
|
bytecode_and_metadata_size: number;
|
|
39
39
|
external_script_source_size: number;
|
|
40
40
|
}
|
|
41
|
+
interface HeapSnapshotOptions {
|
|
42
|
+
/**
|
|
43
|
+
* If true, expose internals in the heap snapshot.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
exposeInternals?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* If true, expose numeric values in artificial fields.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
exposeNumericValues?: boolean;
|
|
52
|
+
}
|
|
41
53
|
/**
|
|
42
54
|
* Returns an integer representing a version tag derived from the V8 version,
|
|
43
55
|
* command-line flags, and detected CPU features. This is useful for determining
|
|
@@ -105,7 +117,7 @@ declare module "v8" {
|
|
|
105
117
|
* Returns statistics about the V8 heap spaces, i.e. the segments which make up
|
|
106
118
|
* the V8 heap. Neither the ordering of heap spaces, nor the availability of a
|
|
107
119
|
* heap space can be guaranteed as the statistics are provided via 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
|
|
120
|
+
* 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
|
|
109
121
|
* next.
|
|
110
122
|
*
|
|
111
123
|
* The value returned is an array of objects containing the following properties:
|
|
@@ -194,7 +206,7 @@ declare module "v8" {
|
|
|
194
206
|
* @since v11.13.0
|
|
195
207
|
* @return A Readable containing the V8 heap snapshot.
|
|
196
208
|
*/
|
|
197
|
-
function getHeapSnapshot(): Readable;
|
|
209
|
+
function getHeapSnapshot(options?: HeapSnapshotOptions): Readable;
|
|
198
210
|
/**
|
|
199
211
|
* Generates a snapshot of the current V8 heap and writes it to a JSON
|
|
200
212
|
* file. This file is intended to be used with tools such as Chrome
|
|
@@ -246,10 +258,10 @@ declare module "v8" {
|
|
|
246
258
|
* worker thread.
|
|
247
259
|
* @return The filename where the snapshot was saved.
|
|
248
260
|
*/
|
|
249
|
-
function writeHeapSnapshot(filename?: string): string;
|
|
261
|
+
function writeHeapSnapshot(filename?: string, options?: HeapSnapshotOptions): string;
|
|
250
262
|
/**
|
|
251
263
|
* 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
|
|
264
|
+
* V8 [`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the
|
|
253
265
|
* following properties:
|
|
254
266
|
*
|
|
255
267
|
* ```js
|
|
@@ -408,6 +420,13 @@ declare module "v8" {
|
|
|
408
420
|
* @since v15.1.0, v14.18.0, v12.22.0
|
|
409
421
|
*/
|
|
410
422
|
function stopCoverage(): void;
|
|
423
|
+
/**
|
|
424
|
+
* 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.
|
|
425
|
+
* `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--heapsnapshot-near-heap-limitmax_count) for more information.
|
|
426
|
+
* @experimental
|
|
427
|
+
* @since v18.10.0, v16.18.0
|
|
428
|
+
*/
|
|
429
|
+
function setHeapSnapshotNearHeapLimit(limit: number): void;
|
|
411
430
|
/**
|
|
412
431
|
* This API collects GC data in current thread.
|
|
413
432
|
* @since v19.6.0, v18.15.0
|
|
@@ -629,6 +648,116 @@ declare module "v8" {
|
|
|
629
648
|
* @since v17.1.0, v16.14.0
|
|
630
649
|
*/
|
|
631
650
|
const promiseHooks: PromiseHooks;
|
|
651
|
+
type StartupSnapshotCallbackFn = (args: any) => any;
|
|
652
|
+
interface StartupSnapshot {
|
|
653
|
+
/**
|
|
654
|
+
* Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
|
|
655
|
+
* 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.
|
|
656
|
+
* @since v18.6.0, v16.17.0
|
|
657
|
+
*/
|
|
658
|
+
addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
659
|
+
/**
|
|
660
|
+
* Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
|
|
661
|
+
* 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
|
|
662
|
+
* to re-acquire resources that the application needs when the application is restarted from the snapshot.
|
|
663
|
+
* @since v18.6.0, v16.17.0
|
|
664
|
+
*/
|
|
665
|
+
addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
666
|
+
/**
|
|
667
|
+
* 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.
|
|
668
|
+
* 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
|
|
669
|
+
* data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
|
|
670
|
+
* @since v18.6.0, v16.17.0
|
|
671
|
+
*/
|
|
672
|
+
setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
|
|
673
|
+
/**
|
|
674
|
+
* Returns true if the Node.js instance is run to build a snapshot.
|
|
675
|
+
* @since v18.6.0, v16.17.0
|
|
676
|
+
*/
|
|
677
|
+
isBuildingSnapshot(): boolean;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* The `v8.startupSnapshot` interface can be used to add serialization and deserialization hooks for custom startup snapshots.
|
|
681
|
+
*
|
|
682
|
+
* ```bash
|
|
683
|
+
* $ node --snapshot-blob snapshot.blob --build-snapshot entry.js
|
|
684
|
+
* # This launches a process with the snapshot
|
|
685
|
+
* $ node --snapshot-blob snapshot.blob
|
|
686
|
+
* ```
|
|
687
|
+
*
|
|
688
|
+
* In the example above, `entry.js` can use methods from the `v8.startupSnapshot` interface to specify how to save information for custom objects
|
|
689
|
+
* in the snapshot during serialization and how the information can be used to synchronize these objects during deserialization of the snapshot.
|
|
690
|
+
* For example, if the `entry.js` contains the following script:
|
|
691
|
+
*
|
|
692
|
+
* ```js
|
|
693
|
+
* 'use strict';
|
|
694
|
+
*
|
|
695
|
+
* const fs = require('node:fs');
|
|
696
|
+
* const zlib = require('node:zlib');
|
|
697
|
+
* const path = require('node:path');
|
|
698
|
+
* const assert = require('node:assert');
|
|
699
|
+
*
|
|
700
|
+
* const v8 = require('node:v8');
|
|
701
|
+
*
|
|
702
|
+
* class BookShelf {
|
|
703
|
+
* storage = new Map();
|
|
704
|
+
*
|
|
705
|
+
* // Reading a series of files from directory and store them into storage.
|
|
706
|
+
* constructor(directory, books) {
|
|
707
|
+
* for (const book of books) {
|
|
708
|
+
* this.storage.set(book, fs.readFileSync(path.join(directory, book)));
|
|
709
|
+
* }
|
|
710
|
+
* }
|
|
711
|
+
*
|
|
712
|
+
* static compressAll(shelf) {
|
|
713
|
+
* for (const [ book, content ] of shelf.storage) {
|
|
714
|
+
* shelf.storage.set(book, zlib.gzipSync(content));
|
|
715
|
+
* }
|
|
716
|
+
* }
|
|
717
|
+
*
|
|
718
|
+
* static decompressAll(shelf) {
|
|
719
|
+
* for (const [ book, content ] of shelf.storage) {
|
|
720
|
+
* shelf.storage.set(book, zlib.gunzipSync(content));
|
|
721
|
+
* }
|
|
722
|
+
* }
|
|
723
|
+
* }
|
|
724
|
+
*
|
|
725
|
+
* // __dirname here is where the snapshot script is placed
|
|
726
|
+
* // during snapshot building time.
|
|
727
|
+
* const shelf = new BookShelf(__dirname, [
|
|
728
|
+
* 'book1.en_US.txt',
|
|
729
|
+
* 'book1.es_ES.txt',
|
|
730
|
+
* 'book2.zh_CN.txt',
|
|
731
|
+
* ]);
|
|
732
|
+
*
|
|
733
|
+
* assert(v8.startupSnapshot.isBuildingSnapshot());
|
|
734
|
+
* // On snapshot serialization, compress the books to reduce size.
|
|
735
|
+
* v8.startupSnapshot.addSerializeCallback(BookShelf.compressAll, shelf);
|
|
736
|
+
* // On snapshot deserialization, decompress the books.
|
|
737
|
+
* v8.startupSnapshot.addDeserializeCallback(BookShelf.decompressAll, shelf);
|
|
738
|
+
* v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
|
|
739
|
+
* // process.env and process.argv are refreshed during snapshot
|
|
740
|
+
* // deserialization.
|
|
741
|
+
* const lang = process.env.BOOK_LANG || 'en_US';
|
|
742
|
+
* const book = process.argv[1];
|
|
743
|
+
* const name = `${book}.${lang}.txt`;
|
|
744
|
+
* console.log(shelf.storage.get(name));
|
|
745
|
+
* }, shelf);
|
|
746
|
+
* ```
|
|
747
|
+
*
|
|
748
|
+
* 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:
|
|
749
|
+
*
|
|
750
|
+
* ```bash
|
|
751
|
+
* $ BOOK_LANG=es_ES node --snapshot-blob snapshot.blob book1
|
|
752
|
+
* # Prints content of book1.es_ES.txt deserialized from the snapshot.
|
|
753
|
+
* ```
|
|
754
|
+
*
|
|
755
|
+
* 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.
|
|
756
|
+
*
|
|
757
|
+
* @experimental
|
|
758
|
+
* @since v18.6.0, v16.17.0
|
|
759
|
+
*/
|
|
760
|
+
const startupSnapshot: StartupSnapshot;
|
|
632
761
|
}
|
|
633
762
|
declare module "node:v8" {
|
|
634
763
|
export * from "v8";
|