@types/node 24.10.3 → 25.0.1

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.
Files changed (99) hide show
  1. node v24.10/README.md → node/README.md +2 -2
  2. node v24.10/assert/strict.d.ts → node/assert/strict.d.ts +5 -11
  3. node v24.10/assert.d.ts → node/assert.d.ts +9 -169
  4. node v24.10/async_hooks.d.ts → node/async_hooks.d.ts +8 -8
  5. node v24.10/buffer.buffer.d.ts → node/buffer.buffer.d.ts +1 -7
  6. node v24.10/buffer.d.ts → node/buffer.d.ts +44 -168
  7. node v24.10/child_process.d.ts → node/child_process.d.ts +16 -64
  8. node/cluster.d.ts +486 -0
  9. node/console.d.ts +151 -0
  10. node v24.10/constants.d.ts → node/constants.d.ts +3 -4
  11. node v24.10/crypto.d.ts → node/crypto.d.ts +279 -1631
  12. node v24.10/dgram.d.ts → node/dgram.d.ts +15 -51
  13. node v24.10/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +4 -4
  14. node v24.10/dns/promises.d.ts → node/dns/promises.d.ts +3 -3
  15. node v24.10/dns.d.ts → node/dns.d.ts +131 -132
  16. node v24.10/domain.d.ts → node/domain.d.ts +13 -17
  17. node/events.d.ts +1046 -0
  18. node v24.10/fs/promises.d.ts → node/fs/promises.d.ts +7 -8
  19. node v24.10/fs.d.ts → node/fs.d.ts +417 -455
  20. node v24.10/globals.d.ts → node/globals.d.ts +6 -26
  21. node/globals.typedarray.d.ts +101 -0
  22. node v24.10/http.d.ts → node/http.d.ts +263 -254
  23. node v24.10/http2.d.ts → node/http2.d.ts +528 -804
  24. node v24.10/https.d.ts → node/https.d.ts +59 -239
  25. node v24.10/index.d.ts → node/index.d.ts +15 -1
  26. node/inspector/promises.d.ts +41 -0
  27. node v24.10/inspector.d.ts → node/inspector.d.ts +6 -59
  28. node v24.10/inspector.generated.d.ts → node/inspector.generated.d.ts +3 -10
  29. node v24.10/module.d.ts → node/module.d.ts +47 -122
  30. node v24.10/net.d.ts → node/net.d.ts +63 -184
  31. node v24.10/os.d.ts → node/os.d.ts +6 -6
  32. node v24.10/package.json → node/package.json +2 -2
  33. node/path/posix.d.ts +8 -0
  34. node/path/win32.d.ts +8 -0
  35. node/path.d.ts +187 -0
  36. node/perf_hooks.d.ts +621 -0
  37. node v24.10/process.d.ts → node/process.d.ts +151 -128
  38. node v24.10/punycode.d.ts → node/punycode.d.ts +5 -5
  39. node v24.10/querystring.d.ts → node/querystring.d.ts +4 -4
  40. node/quic.d.ts +910 -0
  41. node v24.10/readline/promises.d.ts → node/readline/promises.d.ts +3 -3
  42. node v24.10/readline.d.ts → node/readline.d.ts +67 -120
  43. node v24.10/repl.d.ts → node/repl.d.ts +75 -98
  44. node v24.10/sea.d.ts → node/sea.d.ts +1 -1
  45. node v24.10/sqlite.d.ts → node/sqlite.d.ts +2 -2
  46. node v24.10/stream/consumers.d.ts → node/stream/consumers.d.ts +10 -10
  47. node/stream/promises.d.ts +211 -0
  48. node/stream/web.d.ts +296 -0
  49. node v24.10/stream.d.ts → node/stream.d.ts +555 -478
  50. node v24.10/string_decoder.d.ts → node/string_decoder.d.ts +4 -4
  51. node/test/reporters.d.ts +96 -0
  52. node v24.10/test.d.ts → node/test.d.ts +80 -180
  53. node v24.10/timers/promises.d.ts → node/timers/promises.d.ts +4 -4
  54. node v24.10/timers.d.ts → node/timers.d.ts +4 -130
  55. node v24.10/tls.d.ts → node/tls.d.ts +102 -177
  56. node v24.10/trace_events.d.ts → node/trace_events.d.ts +9 -9
  57. node v24.10/ts5.6/buffer.buffer.d.ts → node/ts5.6/buffer.buffer.d.ts +1 -7
  58. node v24.10/ts5.6/index.d.ts → node/ts5.6/index.d.ts +15 -1
  59. node v24.10/ts5.7/index.d.ts → node/ts5.7/index.d.ts +15 -1
  60. node v24.10/tty.d.ts → node/tty.d.ts +58 -16
  61. node/url.d.ts +519 -0
  62. node/util/types.d.ts +558 -0
  63. node v24.10/util.d.ts → node/util.d.ts +120 -792
  64. node v24.10/v8.d.ts → node/v8.d.ts +32 -5
  65. node v24.10/vm.d.ts → node/vm.d.ts +13 -13
  66. node v24.10/wasi.d.ts → node/wasi.d.ts +4 -4
  67. node v24.10/web-globals/abortcontroller.d.ts → node/web-globals/abortcontroller.d.ts +27 -2
  68. node/web-globals/blob.d.ts +23 -0
  69. node/web-globals/console.d.ts +9 -0
  70. node v24.10/web-globals/crypto.d.ts → node/web-globals/crypto.d.ts +7 -0
  71. node/web-globals/encoding.d.ts +11 -0
  72. node v24.10/web-globals/events.d.ts → node/web-globals/events.d.ts +9 -0
  73. node v24.10/web-globals/fetch.d.ts → node/web-globals/fetch.d.ts +4 -0
  74. node/web-globals/importmeta.d.ts +13 -0
  75. node/web-globals/messaging.d.ts +23 -0
  76. node/web-globals/performance.d.ts +45 -0
  77. node/web-globals/streams.d.ts +115 -0
  78. node/web-globals/timers.d.ts +44 -0
  79. node/web-globals/url.d.ts +24 -0
  80. node v24.10/worker_threads.d.ts → node/worker_threads.d.ts +176 -358
  81. node v24.10/zlib.d.ts → node/zlib.d.ts +8 -71
  82. node v24.10/cluster.d.ts +0 -578
  83. node v24.10/console.d.ts +0 -453
  84. node v24.10/events.d.ts +0 -976
  85. node v24.10/globals.typedarray.d.ts +0 -41
  86. node v24.10/path.d.ts +0 -200
  87. node v24.10/perf_hooks.d.ts +0 -982
  88. node v24.10/stream/promises.d.ts +0 -90
  89. node v24.10/stream/web.d.ts +0 -573
  90. node v24.10/url.d.ts +0 -1057
  91. node v24.10/web-globals/streams.d.ts +0 -22
  92. {node v24.10 → node}/LICENSE +0 -0
  93. {node v24.10 → node}/compatibility/iterators.d.ts +0 -0
  94. {node v24.10 → node}/ts5.6/compatibility/float16array.d.ts +0 -0
  95. {node v24.10 → node}/ts5.6/globals.typedarray.d.ts +0 -0
  96. {node v24.10 → node}/ts5.7/compatibility/float16array.d.ts +0 -0
  97. {node v24.10 → node}/web-globals/domexception.d.ts +0 -0
  98. {node v24.10 → node}/web-globals/navigator.d.ts +0 -0
  99. {node v24.10 → node}/web-globals/storage.d.ts +0 -0
node/url.d.ts ADDED
@@ -0,0 +1,519 @@
1
+ /**
2
+ * The `node:url` module provides utilities for URL resolution and parsing. It can
3
+ * be accessed using:
4
+ *
5
+ * ```js
6
+ * import url from 'node:url';
7
+ * ```
8
+ * @see [source](https://github.com/nodejs/node/blob/v25.x/lib/url.js)
9
+ */
10
+ declare module "node:url" {
11
+ import { Blob, NonSharedBuffer } from "node:buffer";
12
+ import { ClientRequestArgs } from "node:http";
13
+ import { ParsedUrlQuery, ParsedUrlQueryInput } from "node:querystring";
14
+ // Input to `url.format`
15
+ interface UrlObject {
16
+ auth?: string | null | undefined;
17
+ hash?: string | null | undefined;
18
+ host?: string | null | undefined;
19
+ hostname?: string | null | undefined;
20
+ href?: string | null | undefined;
21
+ pathname?: string | null | undefined;
22
+ protocol?: string | null | undefined;
23
+ search?: string | null | undefined;
24
+ slashes?: boolean | null | undefined;
25
+ port?: string | number | null | undefined;
26
+ query?: string | null | ParsedUrlQueryInput | undefined;
27
+ }
28
+ // Output of `url.parse`
29
+ interface Url {
30
+ auth: string | null;
31
+ hash: string | null;
32
+ host: string | null;
33
+ hostname: string | null;
34
+ href: string;
35
+ path: string | null;
36
+ pathname: string | null;
37
+ protocol: string | null;
38
+ search: string | null;
39
+ slashes: boolean | null;
40
+ port: string | null;
41
+ query: string | null | ParsedUrlQuery;
42
+ }
43
+ interface UrlWithParsedQuery extends Url {
44
+ query: ParsedUrlQuery;
45
+ }
46
+ interface UrlWithStringQuery extends Url {
47
+ query: string | null;
48
+ }
49
+ interface FileUrlToPathOptions {
50
+ /**
51
+ * `true` if the `path` should be return as a windows filepath, `false` for posix, and `undefined` for the system default.
52
+ * @default undefined
53
+ * @since v22.1.0
54
+ */
55
+ windows?: boolean | undefined;
56
+ }
57
+ interface PathToFileUrlOptions {
58
+ /**
59
+ * `true` if the `path` should be return as a windows filepath, `false` for posix, and `undefined` for the system default.
60
+ * @default undefined
61
+ * @since v22.1.0
62
+ */
63
+ windows?: boolean | undefined;
64
+ }
65
+ /**
66
+ * The `url.parse()` method takes a URL string, parses it, and returns a URL
67
+ * object.
68
+ *
69
+ * A `TypeError` is thrown if `urlString` is not a string.
70
+ *
71
+ * A `URIError` is thrown if the `auth` property is present but cannot be decoded.
72
+ *
73
+ * `url.parse()` uses a lenient, non-standard algorithm for parsing URL
74
+ * strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487)
75
+ * and incorrect handling of usernames and passwords. Do not use with untrusted
76
+ * input. CVEs are not issued for `url.parse()` vulnerabilities. Use the
77
+ * [WHATWG URL](https://nodejs.org/docs/latest-v25.x/api/url.html#the-whatwg-url-api) API instead, for example:
78
+ *
79
+ * ```js
80
+ * function getURL(req) {
81
+ * const proto = req.headers['x-forwarded-proto'] || 'https';
82
+ * const host = req.headers['x-forwarded-host'] || req.headers.host || 'example.com';
83
+ * return new URL(req.url || '/', `${proto}://${host}`);
84
+ * }
85
+ * ```
86
+ *
87
+ * The example above assumes well-formed headers are forwarded from a reverse
88
+ * proxy to your Node.js server. If you are not using a reverse proxy, you should
89
+ * use the example below:
90
+ *
91
+ * ```js
92
+ * function getURL(req) {
93
+ * return new URL(req.url || '/', 'https://example.com');
94
+ * }
95
+ * ```
96
+ * @since v0.1.25
97
+ * @deprecated Use the WHATWG URL API instead.
98
+ * @param urlString The URL string to parse.
99
+ * @param parseQueryString If `true`, the `query` property will always
100
+ * be set to an object returned by the [`querystring`](https://nodejs.org/docs/latest-v25.x/api/querystring.html) module's `parse()`
101
+ * method. If `false`, the `query` property on the returned URL object will be an
102
+ * unparsed, undecoded string. **Default:** `false`.
103
+ * @param slashesDenoteHost If `true`, the first token after the literal
104
+ * string `//` and preceding the next `/` will be interpreted as the `host`.
105
+ * For instance, given `//foo/bar`, the result would be
106
+ * `{host: 'foo', pathname: '/bar'}` rather than `{pathname: '//foo/bar'}`.
107
+ * **Default:** `false`.
108
+ */
109
+ function parse(
110
+ urlString: string,
111
+ parseQueryString?: false,
112
+ slashesDenoteHost?: boolean,
113
+ ): UrlWithStringQuery;
114
+ function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
115
+ function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
116
+ /**
117
+ * The `url.format()` method returns a formatted URL string derived from `urlObject`.
118
+ *
119
+ * ```js
120
+ * import url from 'node:url';
121
+ * url.format({
122
+ * protocol: 'https',
123
+ * hostname: 'example.com',
124
+ * pathname: '/some/path',
125
+ * query: {
126
+ * page: 1,
127
+ * format: 'json',
128
+ * },
129
+ * });
130
+ *
131
+ * // => 'https://example.com/some/path?page=1&format=json'
132
+ * ```
133
+ *
134
+ * If `urlObject` is not an object or a string, `url.format()` will throw a `TypeError`.
135
+ *
136
+ * The formatting process operates as follows:
137
+ *
138
+ * * A new empty string `result` is created.
139
+ * * If `urlObject.protocol` is a string, it is appended as-is to `result`.
140
+ * * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
141
+ * * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
142
+ * colon (`:`) character, the literal string `:` will be appended to `result`.
143
+ * * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
144
+ * * `urlObject.slashes` property is true;
145
+ * * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
146
+ * * 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
147
+ * and appended to `result` followed by the literal string `@`.
148
+ * * If the `urlObject.host` property is `undefined` then:
149
+ * * If the `urlObject.hostname` is a string, it is appended to `result`.
150
+ * * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
151
+ * an `Error` is thrown.
152
+ * * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
153
+ * * The literal string `:` is appended to `result`, and
154
+ * * The value of `urlObject.port` is coerced to a string and appended to `result`.
155
+ * * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
156
+ * * If the `urlObject.pathname` property is a string that is not an empty string:
157
+ * * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
158
+ * (`/`), then the literal string `'/'` is appended to `result`.
159
+ * * The value of `urlObject.pathname` is appended to `result`.
160
+ * * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
161
+ * * 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
162
+ * `querystring` module's `stringify()` method passing the value of `urlObject.query`.
163
+ * * Otherwise, if `urlObject.search` is a string:
164
+ * * If the value of `urlObject.search` _does not start_ with the ASCII question
165
+ * mark (`?`) character, the literal string `?` is appended to `result`.
166
+ * * The value of `urlObject.search` is appended to `result`.
167
+ * * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
168
+ * * If the `urlObject.hash` property is a string:
169
+ * * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
170
+ * character, the literal string `#` is appended to `result`.
171
+ * * The value of `urlObject.hash` is appended to `result`.
172
+ * * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
173
+ * string, an `Error` is thrown.
174
+ * * `result` is returned.
175
+ * @since v0.1.25
176
+ * @legacy Use the WHATWG URL API instead.
177
+ * @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()`.
178
+ */
179
+ function format(urlObject: URL, options?: URLFormatOptions): string;
180
+ /**
181
+ * The `url.format()` method returns a formatted URL string derived from `urlObject`.
182
+ *
183
+ * ```js
184
+ * import url from 'node:url';
185
+ * url.format({
186
+ * protocol: 'https',
187
+ * hostname: 'example.com',
188
+ * pathname: '/some/path',
189
+ * query: {
190
+ * page: 1,
191
+ * format: 'json',
192
+ * },
193
+ * });
194
+ *
195
+ * // => 'https://example.com/some/path?page=1&format=json'
196
+ * ```
197
+ *
198
+ * If `urlObject` is not an object or a string, `url.format()` will throw a `TypeError`.
199
+ *
200
+ * The formatting process operates as follows:
201
+ *
202
+ * * A new empty string `result` is created.
203
+ * * If `urlObject.protocol` is a string, it is appended as-is to `result`.
204
+ * * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
205
+ * * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
206
+ * colon (`:`) character, the literal string `:` will be appended to `result`.
207
+ * * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
208
+ * * `urlObject.slashes` property is true;
209
+ * * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
210
+ * * 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
211
+ * and appended to `result` followed by the literal string `@`.
212
+ * * If the `urlObject.host` property is `undefined` then:
213
+ * * If the `urlObject.hostname` is a string, it is appended to `result`.
214
+ * * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
215
+ * an `Error` is thrown.
216
+ * * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
217
+ * * The literal string `:` is appended to `result`, and
218
+ * * The value of `urlObject.port` is coerced to a string and appended to `result`.
219
+ * * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
220
+ * * If the `urlObject.pathname` property is a string that is not an empty string:
221
+ * * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
222
+ * (`/`), then the literal string `'/'` is appended to `result`.
223
+ * * The value of `urlObject.pathname` is appended to `result`.
224
+ * * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
225
+ * * 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
226
+ * `querystring` module's `stringify()` method passing the value of `urlObject.query`.
227
+ * * Otherwise, if `urlObject.search` is a string:
228
+ * * If the value of `urlObject.search` _does not start_ with the ASCII question
229
+ * mark (`?`) character, the literal string `?` is appended to `result`.
230
+ * * The value of `urlObject.search` is appended to `result`.
231
+ * * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
232
+ * * If the `urlObject.hash` property is a string:
233
+ * * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
234
+ * character, the literal string `#` is appended to `result`.
235
+ * * The value of `urlObject.hash` is appended to `result`.
236
+ * * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
237
+ * string, an `Error` is thrown.
238
+ * * `result` is returned.
239
+ * @since v0.1.25
240
+ * @legacy Use the WHATWG URL API instead.
241
+ * @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()`.
242
+ */
243
+ function format(urlObject: UrlObject | string): string;
244
+ /**
245
+ * The `url.resolve()` method resolves a target URL relative to a base URL in a
246
+ * manner similar to that of a web browser resolving an anchor tag.
247
+ *
248
+ * ```js
249
+ * import url from 'node:url';
250
+ * url.resolve('/one/two/three', 'four'); // '/one/two/four'
251
+ * url.resolve('http://example.com/', '/one'); // 'http://example.com/one'
252
+ * url.resolve('http://example.com/one', '/two'); // 'http://example.com/two'
253
+ * ```
254
+ *
255
+ * To achieve the same result using the WHATWG URL API:
256
+ *
257
+ * ```js
258
+ * function resolve(from, to) {
259
+ * const resolvedUrl = new URL(to, new URL(from, 'resolve://'));
260
+ * if (resolvedUrl.protocol === 'resolve:') {
261
+ * // `from` is a relative URL.
262
+ * const { pathname, search, hash } = resolvedUrl;
263
+ * return pathname + search + hash;
264
+ * }
265
+ * return resolvedUrl.toString();
266
+ * }
267
+ *
268
+ * resolve('/one/two/three', 'four'); // '/one/two/four'
269
+ * resolve('http://example.com/', '/one'); // 'http://example.com/one'
270
+ * resolve('http://example.com/one', '/two'); // 'http://example.com/two'
271
+ * ```
272
+ * @since v0.1.25
273
+ * @legacy Use the WHATWG URL API instead.
274
+ * @param from The base URL to use if `to` is a relative URL.
275
+ * @param to The target URL to resolve.
276
+ */
277
+ function resolve(from: string, to: string): string;
278
+ /**
279
+ * Returns the [Punycode](https://tools.ietf.org/html/rfc5891#section-4.4) ASCII serialization of the `domain`. If `domain` is an
280
+ * invalid domain, the empty string is returned.
281
+ *
282
+ * It performs the inverse operation to {@link domainToUnicode}.
283
+ *
284
+ * ```js
285
+ * import url from 'node:url';
286
+ *
287
+ * console.log(url.domainToASCII('español.com'));
288
+ * // Prints xn--espaol-zwa.com
289
+ * console.log(url.domainToASCII('中文.com'));
290
+ * // Prints xn--fiq228c.com
291
+ * console.log(url.domainToASCII('xn--iñvalid.com'));
292
+ * // Prints an empty string
293
+ * ```
294
+ * @since v7.4.0, v6.13.0
295
+ */
296
+ function domainToASCII(domain: string): string;
297
+ /**
298
+ * Returns the Unicode serialization of the `domain`. If `domain` is an invalid
299
+ * domain, the empty string is returned.
300
+ *
301
+ * It performs the inverse operation to {@link domainToASCII}.
302
+ *
303
+ * ```js
304
+ * import url from 'node:url';
305
+ *
306
+ * console.log(url.domainToUnicode('xn--espaol-zwa.com'));
307
+ * // Prints español.com
308
+ * console.log(url.domainToUnicode('xn--fiq228c.com'));
309
+ * // Prints 中文.com
310
+ * console.log(url.domainToUnicode('xn--iñvalid.com'));
311
+ * // Prints an empty string
312
+ * ```
313
+ * @since v7.4.0, v6.13.0
314
+ */
315
+ function domainToUnicode(domain: string): string;
316
+ /**
317
+ * This function ensures the correct decodings of percent-encoded characters as
318
+ * well as ensuring a cross-platform valid absolute path string.
319
+ *
320
+ * ```js
321
+ * import { fileURLToPath } from 'node:url';
322
+ *
323
+ * const __filename = fileURLToPath(import.meta.url);
324
+ *
325
+ * new URL('file:///C:/path/').pathname; // Incorrect: /C:/path/
326
+ * fileURLToPath('file:///C:/path/'); // Correct: C:\path\ (Windows)
327
+ *
328
+ * new URL('file://nas/foo.txt').pathname; // Incorrect: /foo.txt
329
+ * fileURLToPath('file://nas/foo.txt'); // Correct: \\nas\foo.txt (Windows)
330
+ *
331
+ * new URL('file:///你好.txt').pathname; // Incorrect: /%E4%BD%A0%E5%A5%BD.txt
332
+ * fileURLToPath('file:///你好.txt'); // Correct: /你好.txt (POSIX)
333
+ *
334
+ * new URL('file:///hello world').pathname; // Incorrect: /hello%20world
335
+ * fileURLToPath('file:///hello world'); // Correct: /hello world (POSIX)
336
+ * ```
337
+ * @since v10.12.0
338
+ * @param url The file URL string or URL object to convert to a path.
339
+ * @return The fully-resolved platform-specific Node.js file path.
340
+ */
341
+ function fileURLToPath(url: string | URL, options?: FileUrlToPathOptions): string;
342
+ /**
343
+ * Like `url.fileURLToPath(...)` except that instead of returning a string
344
+ * representation of the path, a `Buffer` is returned. This conversion is
345
+ * helpful when the input URL contains percent-encoded segments that are
346
+ * not valid UTF-8 / Unicode sequences.
347
+ * @since v24.3.0
348
+ * @param url The file URL string or URL object to convert to a path.
349
+ * @returns The fully-resolved platform-specific Node.js file path
350
+ * as a `Buffer`.
351
+ */
352
+ function fileURLToPathBuffer(url: string | URL, options?: FileUrlToPathOptions): NonSharedBuffer;
353
+ /**
354
+ * This function ensures that `path` is resolved absolutely, and that the URL
355
+ * control characters are correctly encoded when converting into a File URL.
356
+ *
357
+ * ```js
358
+ * import { pathToFileURL } from 'node:url';
359
+ *
360
+ * new URL('/foo#1', 'file:'); // Incorrect: file:///foo#1
361
+ * pathToFileURL('/foo#1'); // Correct: file:///foo%231 (POSIX)
362
+ *
363
+ * new URL('/some/path%.c', 'file:'); // Incorrect: file:///some/path%.c
364
+ * pathToFileURL('/some/path%.c'); // Correct: file:///some/path%25.c (POSIX)
365
+ * ```
366
+ * @since v10.12.0
367
+ * @param path The path to convert to a File URL.
368
+ * @return The file URL object.
369
+ */
370
+ function pathToFileURL(path: string, options?: PathToFileUrlOptions): URL;
371
+ /**
372
+ * This utility function converts a URL object into an ordinary options object as
373
+ * expected by the `http.request()` and `https.request()` APIs.
374
+ *
375
+ * ```js
376
+ * import { urlToHttpOptions } from 'node:url';
377
+ * const myURL = new URL('https://a:b@測試?abc#foo');
378
+ *
379
+ * console.log(urlToHttpOptions(myURL));
380
+ * /*
381
+ * {
382
+ * protocol: 'https:',
383
+ * hostname: 'xn--g6w251d',
384
+ * hash: '#foo',
385
+ * search: '?abc',
386
+ * pathname: '/',
387
+ * path: '/?abc',
388
+ * href: 'https://a:b@xn--g6w251d/?abc#foo',
389
+ * auth: 'a:b'
390
+ * }
391
+ *
392
+ * ```
393
+ * @since v15.7.0, v14.18.0
394
+ * @param url The `WHATWG URL` object to convert to an options object.
395
+ * @return Options object
396
+ */
397
+ function urlToHttpOptions(url: URL): ClientRequestArgs;
398
+ interface URLFormatOptions {
399
+ /**
400
+ * `true` if the serialized URL string should include the username and password, `false` otherwise.
401
+ * @default true
402
+ */
403
+ auth?: boolean | undefined;
404
+ /**
405
+ * `true` if the serialized URL string should include the fragment, `false` otherwise.
406
+ * @default true
407
+ */
408
+ fragment?: boolean | undefined;
409
+ /**
410
+ * `true` if the serialized URL string should include the search query, `false` otherwise.
411
+ * @default true
412
+ */
413
+ search?: boolean | undefined;
414
+ /**
415
+ * `true` if Unicode characters appearing in the host component of the URL string should be encoded directly as opposed to
416
+ * being Punycode encoded.
417
+ * @default false
418
+ */
419
+ unicode?: boolean | undefined;
420
+ }
421
+ // #region web types
422
+ type URLPatternInput = string | URLPatternInit;
423
+ interface URLPatternComponentResult {
424
+ input: string;
425
+ groups: Record<string, string | undefined>;
426
+ }
427
+ interface URLPatternInit {
428
+ protocol?: string;
429
+ username?: string;
430
+ password?: string;
431
+ hostname?: string;
432
+ port?: string;
433
+ pathname?: string;
434
+ search?: string;
435
+ hash?: string;
436
+ baseURL?: string;
437
+ }
438
+ interface URLPatternOptions {
439
+ ignoreCase?: boolean;
440
+ }
441
+ interface URLPatternResult {
442
+ inputs: URLPatternInput[];
443
+ protocol: URLPatternComponentResult;
444
+ username: URLPatternComponentResult;
445
+ password: URLPatternComponentResult;
446
+ hostname: URLPatternComponentResult;
447
+ port: URLPatternComponentResult;
448
+ pathname: URLPatternComponentResult;
449
+ search: URLPatternComponentResult;
450
+ hash: URLPatternComponentResult;
451
+ }
452
+ interface URL {
453
+ hash: string;
454
+ host: string;
455
+ hostname: string;
456
+ href: string;
457
+ readonly origin: string;
458
+ password: string;
459
+ pathname: string;
460
+ port: string;
461
+ protocol: string;
462
+ search: string;
463
+ readonly searchParams: URLSearchParams;
464
+ username: string;
465
+ toJSON(): string;
466
+ }
467
+ var URL: {
468
+ prototype: URL;
469
+ new(url: string | URL, base?: string | URL): URL;
470
+ canParse(input: string | URL, base?: string | URL): boolean;
471
+ createObjectURL(blob: Blob): string;
472
+ parse(input: string | URL, base?: string | URL): URL | null;
473
+ revokeObjectURL(id: string): void;
474
+ };
475
+ interface URLPattern {
476
+ readonly hasRegExpGroups: boolean;
477
+ readonly hash: string;
478
+ readonly hostname: string;
479
+ readonly password: string;
480
+ readonly pathname: string;
481
+ readonly port: string;
482
+ readonly protocol: string;
483
+ readonly search: string;
484
+ readonly username: string;
485
+ exec(input?: URLPatternInput, baseURL?: string | URL): URLPatternResult | null;
486
+ test(input?: URLPatternInput, baseURL?: string | URL): boolean;
487
+ }
488
+ var URLPattern: {
489
+ prototype: URLPattern;
490
+ new(input: URLPatternInput, baseURL: string | URL, options?: URLPatternOptions): URLPattern;
491
+ new(input?: URLPatternInput, options?: URLPatternOptions): URLPattern;
492
+ };
493
+ interface URLSearchParams {
494
+ readonly size: number;
495
+ append(name: string, value: string): void;
496
+ delete(name: string, value?: string): void;
497
+ get(name: string): string | null;
498
+ getAll(name: string): string[];
499
+ has(name: string, value?: string): boolean;
500
+ set(name: string, value: string): void;
501
+ sort(): void;
502
+ forEach(callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any): void;
503
+ [Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
504
+ entries(): URLSearchParamsIterator<[string, string]>;
505
+ keys(): URLSearchParamsIterator<string>;
506
+ values(): URLSearchParamsIterator<string>;
507
+ }
508
+ var URLSearchParams: {
509
+ prototype: URLSearchParams;
510
+ new(init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
511
+ };
512
+ interface URLSearchParamsIterator<T> extends NodeJS.Iterator<T, NodeJS.BuiltinIteratorReturn, unknown> {
513
+ [Symbol.iterator](): URLSearchParamsIterator<T>;
514
+ }
515
+ // #endregion
516
+ }
517
+ declare module "url" {
518
+ export * from "node:url";
519
+ }