@types/node 16.11.39 → 18.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {node v16.11 → node}/LICENSE +0 -0
- node v16.11/README.md → node/README.md +4 -4
- {node v16.11 → node}/assert/strict.d.ts +0 -0
- node v16.11/assert.d.ts → node/assert.d.ts +7 -8
- node v16.11/async_hooks.d.ts → node/async_hooks.d.ts +8 -4
- node/buffer.d.ts +2258 -0
- node v16.11/child_process.d.ts → node/child_process.d.ts +6 -3
- node v16.11/cluster.d.ts → node/cluster.d.ts +14 -18
- node v16.11/console.d.ts → node/console.d.ts +1 -1
- {node v16.11 → node}/constants.d.ts +0 -0
- node v16.11/crypto.d.ts → node/crypto.d.ts +679 -53
- node v16.11/dgram.d.ts → node/dgram.d.ts +3 -3
- node v16.11/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +2 -1
- node v16.11/dns/promises.d.ts → node/dns/promises.d.ts +10 -8
- node v16.11/dns.d.ts → node/dns.d.ts +16 -11
- node/dom-events.d.ts +126 -0
- node v16.11/domain.d.ts → node/domain.d.ts +3 -2
- node v16.11/events.d.ts → node/events.d.ts +65 -10
- node v16.11/fs/promises.d.ts → node/fs/promises.d.ts +86 -39
- node v16.11/fs.d.ts → node/fs.d.ts +149 -67
- node/globals.d.ts +300 -0
- {node v16.11 → node}/globals.global.d.ts +0 -0
- node v16.11/http.d.ts → node/http.d.ts +305 -77
- node v16.11/http2.d.ts → node/http2.d.ts +38 -5
- node v16.11/https.d.ts → node/https.d.ts +209 -59
- node v16.11/index.d.ts → node/index.d.ts +6 -3
- node v16.11/inspector.d.ts → node/inspector.d.ts +11 -15
- {node v16.11 → node}/module.d.ts +0 -0
- node v16.11/net.d.ts → node/net.d.ts +94 -21
- node v16.11/os.d.ts → node/os.d.ts +15 -4
- node v16.11/package.json → node/package.json +15 -8
- node v16.11/path.d.ts → node/path.d.ts +34 -23
- node v16.11/perf_hooks.d.ts → node/perf_hooks.d.ts +76 -8
- node v16.11/process.d.ts → node/process.d.ts +17 -16
- node v16.11/punycode.d.ts → node/punycode.d.ts +1 -1
- node v16.11/querystring.d.ts → node/querystring.d.ts +4 -4
- node/readline/promises.d.ts +143 -0
- node v16.11/readline.d.ts → node/readline.d.ts +140 -30
- node v16.11/repl.d.ts → node/repl.d.ts +2 -2
- node v16.11/stream/consumers.d.ts → node/stream/consumers.d.ts +2 -14
- {node v16.11 → node}/stream/promises.d.ts +0 -0
- node v16.11/stream/web.d.ts → node/stream/web.d.ts +3 -65
- node v16.11/stream.d.ts → node/stream.d.ts +97 -19
- node v16.11/string_decoder.d.ts → node/string_decoder.d.ts +1 -1
- node/test.d.ts +314 -0
- {node v16.11 → node}/timers/promises.d.ts +0 -0
- node v16.11/timers.d.ts → node/timers.d.ts +1 -1
- node v16.11/tls.d.ts → node/tls.d.ts +32 -23
- node v16.11/trace_events.d.ts → node/trace_events.d.ts +11 -1
- node/ts4.8/assert/strict.d.ts +8 -0
- node/ts4.8/assert.d.ts +911 -0
- node/ts4.8/async_hooks.d.ts +501 -0
- node v16.11/buffer.d.ts → node/ts4.8/buffer.d.ts +46 -19
- node/ts4.8/child_process.d.ts +1369 -0
- node/ts4.8/cluster.d.ts +410 -0
- node/ts4.8/console.d.ts +412 -0
- node/ts4.8/constants.d.ts +18 -0
- node/ts4.8/crypto.d.ts +3964 -0
- node/ts4.8/dgram.d.ts +545 -0
- node/ts4.8/diagnostics_channel.d.ts +153 -0
- node/ts4.8/dns/promises.d.ts +370 -0
- node/ts4.8/dns.d.ts +659 -0
- node/ts4.8/dom-events.d.ts +126 -0
- node/ts4.8/domain.d.ts +170 -0
- node/ts4.8/events.d.ts +678 -0
- node/ts4.8/fs/promises.d.ts +1138 -0
- node/ts4.8/fs.d.ts +3872 -0
- node v16.11/globals.d.ts → node/ts4.8/globals.d.ts +14 -4
- node/ts4.8/globals.global.d.ts +1 -0
- node/ts4.8/http.d.ts +1607 -0
- node/ts4.8/http2.d.ts +2134 -0
- node/ts4.8/https.d.ts +541 -0
- node/ts4.8/index.d.ts +88 -0
- node/ts4.8/inspector.d.ts +2741 -0
- node/ts4.8/module.d.ts +114 -0
- node/ts4.8/net.d.ts +869 -0
- node/ts4.8/os.d.ts +466 -0
- node/ts4.8/path.d.ts +191 -0
- node/ts4.8/perf_hooks.d.ts +625 -0
- node/ts4.8/process.d.ts +1482 -0
- node/ts4.8/punycode.d.ts +117 -0
- node/ts4.8/querystring.d.ts +131 -0
- node/ts4.8/readline/promises.d.ts +143 -0
- node/ts4.8/readline.d.ts +653 -0
- node/ts4.8/repl.d.ts +424 -0
- node/ts4.8/stream/consumers.d.ts +12 -0
- node/ts4.8/stream/promises.d.ts +42 -0
- node/ts4.8/stream/web.d.ts +330 -0
- node/ts4.8/stream.d.ts +1340 -0
- node/ts4.8/string_decoder.d.ts +67 -0
- node/ts4.8/test.d.ts +314 -0
- node/ts4.8/timers/promises.d.ts +68 -0
- node/ts4.8/timers.d.ts +94 -0
- node/ts4.8/tls.d.ts +1028 -0
- node/ts4.8/trace_events.d.ts +171 -0
- node v16.11/tty.d.ts → node/ts4.8/tty.d.ts +4 -2
- node v16.11/url.d.ts → node/ts4.8/url.d.ts +85 -39
- node v16.11/util.d.ts → node/ts4.8/util.d.ts +268 -12
- node v16.11/v8.d.ts → node/ts4.8/v8.d.ts +21 -3
- node v16.11/vm.d.ts → node/ts4.8/vm.d.ts +6 -4
- node v16.11/wasi.d.ts → node/ts4.8/wasi.d.ts +1 -1
- node v16.11/worker_threads.d.ts → node/ts4.8/worker_threads.d.ts +50 -10
- node v16.11/zlib.d.ts → node/ts4.8/zlib.d.ts +1 -1
- node/tty.d.ts +206 -0
- node/url.d.ts +897 -0
- node/util.d.ts +1850 -0
- node/v8.d.ts +396 -0
- node/vm.d.ts +509 -0
- node/wasi.d.ts +158 -0
- node/worker_threads.d.ts +689 -0
- node/zlib.d.ts +517 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `trace_events` module provides a mechanism to centralize tracing information
|
|
3
|
+
* generated by V8, Node.js core, and userspace code.
|
|
4
|
+
*
|
|
5
|
+
* Tracing can be enabled with the `--trace-event-categories` command-line flag
|
|
6
|
+
* or by using the `trace_events` module. The `--trace-event-categories` flag
|
|
7
|
+
* accepts a list of comma-separated category names.
|
|
8
|
+
*
|
|
9
|
+
* The available categories are:
|
|
10
|
+
*
|
|
11
|
+
* * `node`: An empty placeholder.
|
|
12
|
+
* * `node.async_hooks`: Enables capture of detailed `async_hooks` trace data.
|
|
13
|
+
* The `async_hooks` events have a unique `asyncId` and a special `triggerId` `triggerAsyncId` property.
|
|
14
|
+
* * `node.bootstrap`: Enables capture of Node.js bootstrap milestones.
|
|
15
|
+
* * `node.console`: Enables capture of `console.time()` and `console.count()`output.
|
|
16
|
+
* * `node.dns.native`: Enables capture of trace data for DNS queries.
|
|
17
|
+
* * `node.environment`: Enables capture of Node.js Environment milestones.
|
|
18
|
+
* * `node.fs.sync`: Enables capture of trace data for file system sync methods.
|
|
19
|
+
* * `node.perf`: Enables capture of `Performance API` measurements.
|
|
20
|
+
* * `node.perf.usertiming`: Enables capture of only Performance API User Timing
|
|
21
|
+
* measures and marks.
|
|
22
|
+
* * `node.perf.timerify`: Enables capture of only Performance API timerify
|
|
23
|
+
* measurements.
|
|
24
|
+
* * `node.promises.rejections`: Enables capture of trace data tracking the number
|
|
25
|
+
* of unhandled Promise rejections and handled-after-rejections.
|
|
26
|
+
* * `node.vm.script`: Enables capture of trace data for the `vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods.
|
|
27
|
+
* * `v8`: The `V8` events are GC, compiling, and execution related.
|
|
28
|
+
*
|
|
29
|
+
* By default the `node`, `node.async_hooks`, and `v8` categories are enabled.
|
|
30
|
+
*
|
|
31
|
+
* ```bash
|
|
32
|
+
* node --trace-event-categories v8,node,node.async_hooks server.js
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* Prior versions of Node.js required the use of the `--trace-events-enabled`flag to enable trace events. This requirement has been removed. However, the`--trace-events-enabled` flag _may_ still be
|
|
36
|
+
* used and will enable the`node`, `node.async_hooks`, and `v8` trace event categories by default.
|
|
37
|
+
*
|
|
38
|
+
* ```bash
|
|
39
|
+
* node --trace-events-enabled
|
|
40
|
+
*
|
|
41
|
+
* # is equivalent to
|
|
42
|
+
*
|
|
43
|
+
* node --trace-event-categories v8,node,node.async_hooks
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* Alternatively, trace events may be enabled using the `trace_events` module:
|
|
47
|
+
*
|
|
48
|
+
* ```js
|
|
49
|
+
* const trace_events = require('trace_events');
|
|
50
|
+
* const tracing = trace_events.createTracing({ categories: ['node.perf'] });
|
|
51
|
+
* tracing.enable(); // Enable trace event capture for the 'node.perf' category
|
|
52
|
+
*
|
|
53
|
+
* // do work
|
|
54
|
+
*
|
|
55
|
+
* tracing.disable(); // Disable trace event capture for the 'node.perf' category
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* Running Node.js with tracing enabled will produce log files that can be opened
|
|
59
|
+
* in the [`chrome://tracing`](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool) tab of Chrome.
|
|
60
|
+
*
|
|
61
|
+
* The logging file is by default called `node_trace.${rotation}.log`, where`${rotation}` is an incrementing log-rotation id. The filepath pattern can
|
|
62
|
+
* be specified with `--trace-event-file-pattern` that accepts a template
|
|
63
|
+
* string that supports `${rotation}` and `${pid}`:
|
|
64
|
+
*
|
|
65
|
+
* ```bash
|
|
66
|
+
* node --trace-event-categories v8 --trace-event-file-pattern '${pid}-${rotation}.log' server.js
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* To guarantee that the log file is properly generated after signal events like`SIGINT`, `SIGTERM`, or `SIGBREAK`, make sure to have the appropriate handlers
|
|
70
|
+
* in your code, such as:
|
|
71
|
+
*
|
|
72
|
+
* ```js
|
|
73
|
+
* process.on('SIGINT', function onSigint() {
|
|
74
|
+
* console.info('Received SIGINT.');
|
|
75
|
+
* process.exit(130); // Or applicable exit code depending on OS and signal
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* The tracing system uses the same time source
|
|
80
|
+
* as the one used by `process.hrtime()`.
|
|
81
|
+
* However the trace-event timestamps are expressed in microseconds,
|
|
82
|
+
* unlike `process.hrtime()` which returns nanoseconds.
|
|
83
|
+
*
|
|
84
|
+
* The features from this module are not available in `Worker` threads.
|
|
85
|
+
* @experimental
|
|
86
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/trace_events.js)
|
|
87
|
+
*/
|
|
88
|
+
declare module 'trace_events' {
|
|
89
|
+
/**
|
|
90
|
+
* The `Tracing` object is used to enable or disable tracing for sets of
|
|
91
|
+
* categories. Instances are created using the
|
|
92
|
+
* `trace_events.createTracing()` method.
|
|
93
|
+
*
|
|
94
|
+
* When created, the `Tracing` object is disabled. Calling the
|
|
95
|
+
* `tracing.enable()` method adds the categories to the set of enabled trace
|
|
96
|
+
* event categories. Calling `tracing.disable()` will remove the categories
|
|
97
|
+
* from the set of enabled trace event categories.
|
|
98
|
+
*/
|
|
99
|
+
interface Tracing {
|
|
100
|
+
/**
|
|
101
|
+
* A comma-separated list of the trace event categories covered by this
|
|
102
|
+
* `Tracing` object.
|
|
103
|
+
*/
|
|
104
|
+
readonly categories: string;
|
|
105
|
+
/**
|
|
106
|
+
* Disables this `Tracing` object.
|
|
107
|
+
*
|
|
108
|
+
* Only trace event categories _not_ covered by other enabled `Tracing`
|
|
109
|
+
* objects and _not_ specified by the `--trace-event-categories` flag
|
|
110
|
+
* will be disabled.
|
|
111
|
+
*/
|
|
112
|
+
disable(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Enables this `Tracing` object for the set of categories covered by
|
|
115
|
+
* the `Tracing` object.
|
|
116
|
+
*/
|
|
117
|
+
enable(): void;
|
|
118
|
+
/**
|
|
119
|
+
* `true` only if the `Tracing` object has been enabled.
|
|
120
|
+
*/
|
|
121
|
+
readonly enabled: boolean;
|
|
122
|
+
}
|
|
123
|
+
interface CreateTracingOptions {
|
|
124
|
+
/**
|
|
125
|
+
* An array of trace category names. Values included in the array are
|
|
126
|
+
* coerced to a string when possible. An error will be thrown if the
|
|
127
|
+
* value cannot be coerced.
|
|
128
|
+
*/
|
|
129
|
+
categories: string[];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Creates and returns a `Tracing` object for the given set of `categories`.
|
|
133
|
+
*
|
|
134
|
+
* ```js
|
|
135
|
+
* const trace_events = require('trace_events');
|
|
136
|
+
* const categories = ['node.perf', 'node.async_hooks'];
|
|
137
|
+
* const tracing = trace_events.createTracing({ categories });
|
|
138
|
+
* tracing.enable();
|
|
139
|
+
* // do stuff
|
|
140
|
+
* tracing.disable();
|
|
141
|
+
* ```
|
|
142
|
+
* @since v10.0.0
|
|
143
|
+
* @return .
|
|
144
|
+
*/
|
|
145
|
+
function createTracing(options: CreateTracingOptions): Tracing;
|
|
146
|
+
/**
|
|
147
|
+
* Returns a comma-separated list of all currently-enabled trace event
|
|
148
|
+
* categories. The current set of enabled trace event categories is determined
|
|
149
|
+
* by the _union_ of all currently-enabled `Tracing` objects and any categories
|
|
150
|
+
* enabled using the `--trace-event-categories` flag.
|
|
151
|
+
*
|
|
152
|
+
* Given the file `test.js` below, the command`node --trace-event-categories node.perf test.js` will print`'node.async_hooks,node.perf'` to the console.
|
|
153
|
+
*
|
|
154
|
+
* ```js
|
|
155
|
+
* const trace_events = require('trace_events');
|
|
156
|
+
* const t1 = trace_events.createTracing({ categories: ['node.async_hooks'] });
|
|
157
|
+
* const t2 = trace_events.createTracing({ categories: ['node.perf'] });
|
|
158
|
+
* const t3 = trace_events.createTracing({ categories: ['v8'] });
|
|
159
|
+
*
|
|
160
|
+
* t1.enable();
|
|
161
|
+
* t2.enable();
|
|
162
|
+
*
|
|
163
|
+
* console.log(trace_events.getEnabledCategories());
|
|
164
|
+
* ```
|
|
165
|
+
* @since v10.0.0
|
|
166
|
+
*/
|
|
167
|
+
function getEnabledCategories(): string | undefined;
|
|
168
|
+
}
|
|
169
|
+
declare module 'node:trace_events' {
|
|
170
|
+
export * from 'trace_events';
|
|
171
|
+
}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* In most cases, there should be little to no reason for an application to
|
|
24
24
|
* manually create instances of the `tty.ReadStream` and `tty.WriteStream`classes.
|
|
25
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
25
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/tty.js)
|
|
26
26
|
*/
|
|
27
27
|
declare module 'tty' {
|
|
28
28
|
import * as net from 'node:net';
|
|
@@ -52,7 +52,9 @@ declare module 'tty' {
|
|
|
52
52
|
*
|
|
53
53
|
* When in raw mode, input is always available character-by-character, not
|
|
54
54
|
* including modifiers. Additionally, all special processing of characters by the
|
|
55
|
-
* terminal is disabled, including echoing input
|
|
55
|
+
* terminal is disabled, including echoing input
|
|
56
|
+
* characters. Ctrl+C will no longer cause a `SIGINT` when
|
|
57
|
+
* in this mode.
|
|
56
58
|
* @since v0.7.7
|
|
57
59
|
* @param mode If `true`, configures the `tty.ReadStream` to operate as a raw device. If `false`, configures the `tty.ReadStream` to operate in its default mode. The `readStream.isRaw`
|
|
58
60
|
* property will be set to the resulting mode.
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* ```js
|
|
6
6
|
* import url from 'url';
|
|
7
7
|
* ```
|
|
8
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
8
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/url.js)
|
|
9
9
|
*/
|
|
10
10
|
declare module 'url' {
|
|
11
|
-
import { Blob } from 'node:buffer';
|
|
11
|
+
import { Blob as NodeBlob } from 'node:buffer';
|
|
12
12
|
import { ClientRequestArgs } from 'node:http';
|
|
13
13
|
import { ParsedUrlQuery, ParsedUrlQueryInput } from 'node:querystring';
|
|
14
14
|
// Input to `url.format`
|
|
@@ -59,8 +59,12 @@ declare module 'url' {
|
|
|
59
59
|
* lenient, non-standard algorithm for parsing URL strings, security
|
|
60
60
|
* issues can be introduced. Specifically, issues with [host name spoofing](https://hackerone.com/reports/678487) and
|
|
61
61
|
* incorrect handling of usernames and passwords have been identified.
|
|
62
|
+
*
|
|
63
|
+
* Deprecation of this API has been shelved for now primarily due to the the
|
|
64
|
+
* inability of the [WHATWG API to parse relative URLs](https://github.com/nodejs/node/issues/12682#issuecomment-1154492373).
|
|
65
|
+
* [Discussions are ongoing](https://github.com/whatwg/url/issues/531) for the best way to resolve this.
|
|
66
|
+
*
|
|
62
67
|
* @since v0.1.25
|
|
63
|
-
* @deprecated Legacy: Use the WHATWG URL API instead.
|
|
64
68
|
* @param urlString The URL string to parse.
|
|
65
69
|
* @param [parseQueryString=false] If `true`, the `query` property will always be set to an object returned by the {@link querystring} module's `parse()` method. If `false`, the `query` property
|
|
66
70
|
* on the returned URL object will be an unparsed, undecoded string.
|
|
@@ -72,27 +76,67 @@ declare module 'url' {
|
|
|
72
76
|
function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
|
|
73
77
|
function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
|
|
74
78
|
/**
|
|
75
|
-
* The
|
|
76
|
-
* These are not, however, customizable in any way. The `url.format(URL[, options])` method allows for basic
|
|
77
|
-
* customization of the output.
|
|
78
|
-
* Returns a customizable serialization of a URL `String` representation of a `WHATWG URL` object.
|
|
79
|
+
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
79
80
|
*
|
|
80
81
|
* ```js
|
|
81
|
-
*
|
|
82
|
-
*
|
|
82
|
+
* const url = require('url');
|
|
83
|
+
* url.format({
|
|
84
|
+
* protocol: 'https',
|
|
85
|
+
* hostname: 'example.com',
|
|
86
|
+
* pathname: '/some/path',
|
|
87
|
+
* query: {
|
|
88
|
+
* page: 1,
|
|
89
|
+
* format: 'json'
|
|
90
|
+
* }
|
|
91
|
+
* });
|
|
83
92
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
93
|
+
* // => 'https://example.com/some/path?page=1&format=json'
|
|
94
|
+
* ```
|
|
86
95
|
*
|
|
87
|
-
*
|
|
88
|
-
* // Prints https://a:b@xn--g6w251d/?abc#foo
|
|
96
|
+
* If `urlObject` is not an object or a string, `url.format()` will throw a `TypeError`.
|
|
89
97
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
98
|
+
* The formatting process operates as follows:
|
|
99
|
+
*
|
|
100
|
+
* * A new empty string `result` is created.
|
|
101
|
+
* * If `urlObject.protocol` is a string, it is appended as-is to `result`.
|
|
102
|
+
* * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
|
|
103
|
+
* * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
|
|
104
|
+
* colon (`:`) character, the literal string `:` will be appended to `result`.
|
|
105
|
+
* * If either of the following conditions is true, then the literal string `//`will be appended to `result`:
|
|
106
|
+
* * `urlObject.slashes` property is true;
|
|
107
|
+
* * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`;
|
|
108
|
+
* * 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
|
|
109
|
+
* and appended to `result`followed by the literal string `@`.
|
|
110
|
+
* * If the `urlObject.host` property is `undefined` then:
|
|
111
|
+
* * If the `urlObject.hostname` is a string, it is appended to `result`.
|
|
112
|
+
* * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
|
|
113
|
+
* an `Error` is thrown.
|
|
114
|
+
* * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`:
|
|
115
|
+
* * The literal string `:` is appended to `result`, and
|
|
116
|
+
* * The value of `urlObject.port` is coerced to a string and appended to`result`.
|
|
117
|
+
* * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`.
|
|
118
|
+
* * If the `urlObject.pathname` property is a string that is not an empty string:
|
|
119
|
+
* * If the `urlObject.pathname`_does not start_ with an ASCII forward slash
|
|
120
|
+
* (`/`), then the literal string `'/'` is appended to `result`.
|
|
121
|
+
* * The value of `urlObject.pathname` is appended to `result`.
|
|
122
|
+
* * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
|
|
123
|
+
* * 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
|
|
124
|
+
* `querystring` module's `stringify()`method passing the value of `urlObject.query`.
|
|
125
|
+
* * Otherwise, if `urlObject.search` is a string:
|
|
126
|
+
* * If the value of `urlObject.search`_does not start_ with the ASCII question
|
|
127
|
+
* mark (`?`) character, the literal string `?` is appended to `result`.
|
|
128
|
+
* * The value of `urlObject.search` is appended to `result`.
|
|
129
|
+
* * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
|
|
130
|
+
* * If the `urlObject.hash` property is a string:
|
|
131
|
+
* * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`)
|
|
132
|
+
* character, the literal string `#` is appended to `result`.
|
|
133
|
+
* * The value of `urlObject.hash` is appended to `result`.
|
|
134
|
+
* * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
|
|
135
|
+
* string, an `Error` is thrown.
|
|
136
|
+
* * `result` is returned.
|
|
137
|
+
* @since v0.1.25
|
|
138
|
+
* @deprecated Legacy: Use the WHATWG URL API instead.
|
|
139
|
+
* @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`.
|
|
96
140
|
*/
|
|
97
141
|
function format(urlObject: URL, options?: URLFormatOptions): string;
|
|
98
142
|
/**
|
|
@@ -161,7 +205,7 @@ declare module 'url' {
|
|
|
161
205
|
function format(urlObject: UrlObject | string): string;
|
|
162
206
|
/**
|
|
163
207
|
* The `url.resolve()` method resolves a target URL relative to a base URL in a
|
|
164
|
-
* manner similar to that of a
|
|
208
|
+
* manner similar to that of a web browser resolving an anchor tag.
|
|
165
209
|
*
|
|
166
210
|
* ```js
|
|
167
211
|
* const url = require('url');
|
|
@@ -170,7 +214,7 @@ declare module 'url' {
|
|
|
170
214
|
* url.resolve('http://example.com/one', '/two'); // 'http://example.com/two'
|
|
171
215
|
* ```
|
|
172
216
|
*
|
|
173
|
-
*
|
|
217
|
+
* To achieve the same result using the WHATWG URL API:
|
|
174
218
|
*
|
|
175
219
|
* ```js
|
|
176
220
|
* function resolve(from, to) {
|
|
@@ -189,8 +233,8 @@ declare module 'url' {
|
|
|
189
233
|
* ```
|
|
190
234
|
* @since v0.1.25
|
|
191
235
|
* @deprecated Legacy: Use the WHATWG URL API instead.
|
|
192
|
-
* @param from The
|
|
193
|
-
* @param to The
|
|
236
|
+
* @param from The base URL to use if `to` is a relative URL.
|
|
237
|
+
* @param to The target URL to resolve.
|
|
194
238
|
*/
|
|
195
239
|
function resolve(from: string, to: string): string;
|
|
196
240
|
/**
|
|
@@ -288,7 +332,7 @@ declare module 'url' {
|
|
|
288
332
|
* const myURL = new URL('https://a:b@測試?abc#foo');
|
|
289
333
|
*
|
|
290
334
|
* console.log(urlToHttpOptions(myURL));
|
|
291
|
-
*
|
|
335
|
+
* /*
|
|
292
336
|
* {
|
|
293
337
|
* protocol: 'https:',
|
|
294
338
|
* hostname: 'xn--g6w251d',
|
|
@@ -301,7 +345,7 @@ declare module 'url' {
|
|
|
301
345
|
* }
|
|
302
346
|
*
|
|
303
347
|
* ```
|
|
304
|
-
* @since v15.7.0
|
|
348
|
+
* @since v15.7.0, v14.18.0
|
|
305
349
|
* @param url The `WHATWG URL` object to convert to an options object.
|
|
306
350
|
* @return Options object
|
|
307
351
|
*/
|
|
@@ -351,9 +395,10 @@ declare module 'url' {
|
|
|
351
395
|
* @since v16.7.0
|
|
352
396
|
* @experimental
|
|
353
397
|
*/
|
|
354
|
-
static createObjectURL(blob:
|
|
398
|
+
static createObjectURL(blob: NodeBlob): string;
|
|
355
399
|
/**
|
|
356
|
-
* Removes the stored `Blob` identified by the given ID.
|
|
400
|
+
* Removes the stored `Blob` identified by the given ID. Attempting to revoke a
|
|
401
|
+
* ID that isn’t registered will silently fail.
|
|
357
402
|
* @since v16.7.0
|
|
358
403
|
* @experimental
|
|
359
404
|
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
|
@@ -815,7 +860,6 @@ declare module 'url' {
|
|
|
815
860
|
values(): IterableIterator<string>;
|
|
816
861
|
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
817
862
|
}
|
|
818
|
-
|
|
819
863
|
import { URL as _URL, URLSearchParams as _URLSearchParams } from 'url';
|
|
820
864
|
global {
|
|
821
865
|
interface URLSearchParams extends _URLSearchParams {}
|
|
@@ -829,21 +873,23 @@ declare module 'url' {
|
|
|
829
873
|
* https://nodejs.org/api/url.html#the-whatwg-url-api
|
|
830
874
|
* @since v10.0.0
|
|
831
875
|
*/
|
|
832
|
-
var URL:
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
876
|
+
var URL: typeof globalThis extends {
|
|
877
|
+
onmessage: any;
|
|
878
|
+
URL: infer T;
|
|
879
|
+
}
|
|
880
|
+
? T
|
|
881
|
+
: typeof _URL;
|
|
837
882
|
/**
|
|
838
|
-
* `URLSearchParams` class is a global reference for `require('url').URLSearchParams
|
|
883
|
+
* `URLSearchParams` class is a global reference for `require('url').URLSearchParams`
|
|
839
884
|
* https://nodejs.org/api/url.html#class-urlsearchparams
|
|
840
885
|
* @since v10.0.0
|
|
841
886
|
*/
|
|
842
|
-
var URLSearchParams:
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
887
|
+
var URLSearchParams: typeof globalThis extends {
|
|
888
|
+
onmessage: any;
|
|
889
|
+
URLSearchParams: infer T;
|
|
890
|
+
}
|
|
891
|
+
? T
|
|
892
|
+
: typeof _URLSearchParams;
|
|
847
893
|
}
|
|
848
894
|
}
|
|
849
895
|
declare module 'node:url' {
|