@tothalex/cloud 0.0.40

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.
package/src/url.d.ts ADDED
@@ -0,0 +1,774 @@
1
+ /**
2
+ * The `url` module provides utilities for URL resolution and parsing. It can
3
+ * be accessed using:
4
+ *
5
+ * ```js
6
+ * import url from 'url';
7
+ * ```
8
+ */
9
+ declare module "url" {
10
+ // Output of `url.parse`
11
+ interface Url {
12
+ auth: string | null;
13
+ hash: string | null;
14
+ host: string | null;
15
+ hostname: string | null;
16
+ href: string;
17
+ path: string | null;
18
+ pathname: string | null;
19
+ protocol: string | null;
20
+ search: string | null;
21
+ slashes: boolean | null;
22
+ port: string | null;
23
+ query: string | null;
24
+ }
25
+ interface URLFormatOptions {
26
+ /**
27
+ * `true` if the serialized URL string should include the username and password, `false` otherwise.
28
+ * @default true
29
+ */
30
+ auth?: boolean | undefined;
31
+ /**
32
+ * `true` if the serialized URL string should include the fragment, `false` otherwise.
33
+ * @default true
34
+ */
35
+ fragment?: boolean | undefined;
36
+ /**
37
+ * `true` if the serialized URL string should include the search query, `false` otherwise.
38
+ * @default true
39
+ */
40
+ search?: boolean | undefined;
41
+ /**
42
+ * `true` if Unicode characters appearing in the host component of the URL string should be encoded directly as opposed to
43
+ * being Punycode encoded.
44
+ * @default false
45
+ */
46
+ unicode?: boolean | undefined;
47
+ }
48
+ /**
49
+ * The `url.parse()` method takes a URL string, parses it, and returns a URL
50
+ * object.
51
+ *
52
+ * A `TypeError` is thrown if `urlString` is not a string.
53
+ *
54
+ * A `URIError` is thrown if the `auth` property is present but cannot be decoded.
55
+ *
56
+ * `url.parse()` uses a lenient, non-standard algorithm for parsing URL
57
+ * strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487) and incorrect handling of usernames and passwords. Do not use with untrusted
58
+ * input. CVEs are not issued for `url.parse()` vulnerabilities. Use the `WHATWG URL` API instead.
59
+ * @deprecated Use the WHATWG URL API instead.
60
+ * @param urlString The URL string to parse.
61
+ * @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
62
+ * on the returned URL object will be an unparsed, undecoded string.
63
+ * @param [slashesDenoteHost=false] If `true`, the first token after the literal string `//` and preceding the next `/` will be interpreted as the `host`. For instance, given `//foo/bar`, the
64
+ * result would be `{host: 'foo', pathname: '/bar'}` rather than `{pathname: '//foo/bar'}`.
65
+ */
66
+ function parse(
67
+ urlString: string,
68
+ parseQueryString: boolean,
69
+ slashesDenoteHost?: boolean
70
+ ): Url;
71
+ /**
72
+ * The `url.format()` method returns a formatted URL string derived from `urlObject`.
73
+ *
74
+ * ```js
75
+ * const url = require('url');
76
+ * url.format({
77
+ * protocol: 'https',
78
+ * hostname: 'example.com',
79
+ * pathname: '/some/path',
80
+ * query: {
81
+ * page: 1,
82
+ * format: 'json',
83
+ * },
84
+ * });
85
+ *
86
+ * // => 'https://example.com/some/path?page=1&format=json'
87
+ * ```
88
+ *
89
+ * If `urlObject` is not an object or a string, `url.format()` will throw a `TypeError`.
90
+ *
91
+ * The formatting process operates as follows:
92
+ *
93
+ * * A new empty string `result` is created.
94
+ * * If `urlObject.protocol` is a string, it is appended as-is to `result`.
95
+ * * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown.
96
+ * * For all string values of `urlObject.protocol` that _do not end_ with an ASCII
97
+ * colon (`:`) character, the literal string `:` will be appended to `result`.
98
+ * * If either of the following conditions is true, then the literal string `//` will be appended to `result`:
99
+ * * `urlObject.slashes` property is true;
100
+ * * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or `file`;
101
+ * * 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
102
+ * and appended to `result` followed by the literal string `@`.
103
+ * * If the `urlObject.host` property is `undefined` then:
104
+ * * If the `urlObject.hostname` is a string, it is appended to `result`.
105
+ * * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
106
+ * an `Error` is thrown.
107
+ * * If the `urlObject.port` property value is truthy, and `urlObject.hostname` is not `undefined`:
108
+ * * The literal string `:` is appended to `result`, and
109
+ * * The value of `urlObject.port` is coerced to a string and appended to `result`.
110
+ * * Otherwise, if the `urlObject.host` property value is truthy, the value of `urlObject.host` is coerced to a string and appended to `result`.
111
+ * * If the `urlObject.pathname` property is a string that is not an empty string:
112
+ * * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
113
+ * (`/`), then the literal string `'/'` is appended to `result`.
114
+ * * The value of `urlObject.pathname` is appended to `result`.
115
+ * * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown.
116
+ * * 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
117
+ * `querystring` module's `stringify()` method passing the value of `urlObject.query`.
118
+ * * Otherwise, if `urlObject.search` is a string:
119
+ * * If the value of `urlObject.search` _does not start_ with the ASCII question
120
+ * mark (`?`) character, the literal string `?` is appended to `result`.
121
+ * * The value of `urlObject.search` is appended to `result`.
122
+ * * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown.
123
+ * * If the `urlObject.hash` property is a string:
124
+ * * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
125
+ * character, the literal string `#` is appended to `result`.
126
+ * * The value of `urlObject.hash` is appended to `result`.
127
+ * * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
128
+ * string, an `Error` is thrown.
129
+ * * `result` is returned.
130
+ * @legacy Use the WHATWG URL API instead.
131
+ * @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()`.
132
+ */
133
+ function format(urlObject: URL, options?: URLFormatOptions): string;
134
+ /**
135
+ * Returns the [Punycode](https://tools.ietf.org/html/rfc5891#section-4.4) ASCII serialization of the `domain`. If `domain` is an
136
+ * invalid domain, the empty string is returned.
137
+ *
138
+ * It performs the inverse operation to {@link domainToUnicode}.
139
+ *
140
+ * ```js
141
+ * import url from 'url';
142
+ *
143
+ * console.log(url.domainToASCII('español.com'));
144
+ * // Prints xn--espaol-zwa.com
145
+ * console.log(url.domainToASCII('中文.com'));
146
+ * // Prints xn--fiq228c.com
147
+ * console.log(url.domainToASCII('xn--iñvalid.com'));
148
+ * // Prints an empty string
149
+ * ```
150
+ */
151
+ function domainToASCII(domain: string): string;
152
+ /**
153
+ * Returns the Unicode serialization of the `domain`. If `domain` is an invalid
154
+ * domain, the empty string is returned.
155
+ *
156
+ * It performs the inverse operation to {@link domainToASCII}.
157
+ *
158
+ * ```js
159
+ * import url from 'url';
160
+ *
161
+ * console.log(url.domainToUnicode('xn--espaol-zwa.com'));
162
+ * // Prints español.com
163
+ * console.log(url.domainToUnicode('xn--fiq228c.com'));
164
+ * // Prints 中文.com
165
+ * console.log(url.domainToUnicode('xn--iñvalid.com'));
166
+ * // Prints an empty string
167
+ * ```
168
+ */
169
+ function domainToUnicode(domain: string): string;
170
+ /**
171
+ * This function ensures the correct decodings of percent-encoded characters as
172
+ * well as ensuring a cross-platform valid absolute path string.
173
+ *
174
+ * ```js
175
+ * import { fileURLToPath } from 'url';
176
+ *
177
+ * const __filename = fileURLToPath(import.meta.url);
178
+ *
179
+ * new URL('file:///C:/path/').pathname; // Incorrect: /C:/path/
180
+ * fileURLToPath('file:///C:/path/'); // Correct: C:\path\ (Windows)
181
+ *
182
+ * new URL('file://nas/foo.txt').pathname; // Incorrect: /foo.txt
183
+ * fileURLToPath('file://nas/foo.txt'); // Correct: \\nas\foo.txt (Windows)
184
+ *
185
+ * new URL('file:///你好.txt').pathname; // Incorrect: /%E4%BD%A0%E5%A5%BD.txt
186
+ * fileURLToPath('file:///你好.txt'); // Correct: /你好.txt (POSIX)
187
+ *
188
+ * new URL('file:///hello world').pathname; // Incorrect: /hello%20world
189
+ * fileURLToPath('file:///hello world'); // Correct: /hello world (POSIX)
190
+ * ```
191
+ * @param url The file URL string or URL object to convert to a path.
192
+ * @return The fully-resolved platform-specific Node.js file path.
193
+ */
194
+ function fileURLToPath(url: string | URL): string;
195
+ /**
196
+ * This function ensures that `path` is resolved absolutely, and that the URL
197
+ * control characters are correctly encoded when converting into a File URL.
198
+ *
199
+ * ```js
200
+ * import { pathToFileURL } from 'url';
201
+ *
202
+ * new URL('/foo#1', 'file:'); // Incorrect: file:///foo#1
203
+ * pathToFileURL('/foo#1'); // Correct: file:///foo%231 (POSIX)
204
+ *
205
+ * new URL('/some/path%.c', 'file:'); // Incorrect: file:///some/path%.c
206
+ * pathToFileURL('/some/path%.c'); // Correct: file:///some/path%25.c (POSIX)
207
+ * ```
208
+ * @param path The path to convert to a File URL.
209
+ * @return The file URL object.
210
+ */
211
+ function pathToFileURL(path: string): URL;
212
+ /**
213
+ * This utility function converts a URL object into an ordinary options object as
214
+ * expected by the `http.request()` and `https.request()` APIs.
215
+ *
216
+ * ```js
217
+ * import { urlToHttpOptions } from 'url';
218
+ * const myURL = new URL('https://a:b@測試?abc#foo');
219
+ *
220
+ * console.log(urlToHttpOptions(myURL));
221
+ * /*
222
+ * {
223
+ * protocol: 'https:',
224
+ * hostname: 'xn--g6w251d',
225
+ * hash: '#foo',
226
+ * search: '?abc',
227
+ * pathname: '/',
228
+ * path: '/?abc',
229
+ * href: 'https://a:b@xn--g6w251d/?abc#foo',
230
+ * auth: 'a:b'
231
+ * }
232
+ *
233
+ * ```
234
+ * @param url The `WHATWG URL` object to convert to an options object.
235
+ * @return Options object
236
+ */
237
+ function urlToHttpOptions(url: URL): Object;
238
+ /**
239
+ * Browser-compatible `URL` class, implemented by following the WHATWG URL
240
+ * Standard. [Examples of parsed URLs](https://url.spec.whatwg.org/#example-url-parsing) may be found in the Standard itself.
241
+ * The `URL` class is also available on the global object.
242
+ *
243
+ * In accordance with browser conventions, all properties of `URL` objects
244
+ * are implemented as getters and setters on the class prototype, rather than as
245
+ * data properties on the object itself. Thus, unlike `legacy urlObject`s,
246
+ * 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
247
+ * return `true`.
248
+ */
249
+ class URL {
250
+ /**
251
+ * Checks if an `input` relative to the `base` can be parsed to a `URL`.
252
+ *
253
+ * ```js
254
+ * const isValid = URL.canParse('/foo', 'https://example.org/'); // true
255
+ *
256
+ * const isNotValid = URL.canParse('/foo'); // false
257
+ * ```
258
+ * @param input The absolute or relative input URL to parse. If `input` is relative, then `base` is required. If `input` is absolute, the `base` is ignored. If `input` is not a string, it is
259
+ * `converted to a string` first.
260
+ * @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.
261
+ */
262
+ static canParse(input: string, base?: string): boolean;
263
+ /**
264
+ * Parses a string as a URL. If `base` is provided, it will be used as the base URL for the purpose of resolving non-absolute `input` URLs.
265
+ * Returns `null` if `input` is not a valid.
266
+ * @param input The absolute or relative input URL to parse. If `input` is relative, then `base` is required. If `input` is absolute, the `base` is ignored. If `input` is not a string, it is
267
+ * `converted to a string` first.
268
+ * @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.
269
+ */
270
+ static parse(input: string, base?: string): URL | null;
271
+ constructor(
272
+ input: string | { toString: () => string },
273
+ base?: string | URL
274
+ );
275
+ /**
276
+ * Gets and sets the fragment portion of the URL.
277
+ *
278
+ * ```js
279
+ * const myURL = new URL('https://example.org/foo#bar');
280
+ * console.log(myURL.hash);
281
+ * // Prints #bar
282
+ *
283
+ * myURL.hash = 'baz';
284
+ * console.log(myURL.href);
285
+ * // Prints https://example.org/foo#baz
286
+ * ```
287
+ *
288
+ * Invalid URL characters included in the value assigned to the `hash` property
289
+ * are `percent-encoded`. The selection of which characters to
290
+ * percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
291
+ */
292
+ hash: string;
293
+ /**
294
+ * Gets and sets the host portion of the URL.
295
+ *
296
+ * ```js
297
+ * const myURL = new URL('https://example.org:81/foo');
298
+ * console.log(myURL.host);
299
+ * // Prints example.org:81
300
+ *
301
+ * myURL.host = 'example.com:82';
302
+ * console.log(myURL.href);
303
+ * // Prints https://example.com:82/foo
304
+ * ```
305
+ *
306
+ * Invalid host values assigned to the `host` property are ignored.
307
+ */
308
+ host: string;
309
+ /**
310
+ * Gets and sets the host name portion of the URL. The key difference between`url.host` and `url.hostname` is that `url.hostname` does _not_ include the
311
+ * port.
312
+ *
313
+ * ```js
314
+ * const myURL = new URL('https://example.org:81/foo');
315
+ * console.log(myURL.hostname);
316
+ * // Prints example.org
317
+ *
318
+ * // Setting the hostname does not change the port
319
+ * myURL.hostname = 'example.com';
320
+ * console.log(myURL.href);
321
+ * // Prints https://example.com:81/foo
322
+ *
323
+ * // Use myURL.host to change the hostname and port
324
+ * myURL.host = 'example.org:82';
325
+ * console.log(myURL.href);
326
+ * // Prints https://example.org:82/foo
327
+ * ```
328
+ *
329
+ * Invalid host name values assigned to the `hostname` property are ignored.
330
+ */
331
+ hostname: string;
332
+ /**
333
+ * Gets and sets the serialized URL.
334
+ *
335
+ * ```js
336
+ * const myURL = new URL('https://example.org/foo');
337
+ * console.log(myURL.href);
338
+ * // Prints https://example.org/foo
339
+ *
340
+ * myURL.href = 'https://example.com/bar';
341
+ * console.log(myURL.href);
342
+ * // Prints https://example.com/bar
343
+ * ```
344
+ *
345
+ * Getting the value of the `href` property is equivalent to calling {@link toString}.
346
+ *
347
+ * Setting the value of this property to a new value is equivalent to creating a
348
+ * new `URL` object using `new URL(value)`. Each of the `URL` object's properties will be modified.
349
+ *
350
+ * If the value assigned to the `href` property is not a valid URL, a `TypeError` will be thrown.
351
+ */
352
+ href: string;
353
+ /**
354
+ * Gets the read-only serialization of the URL's origin.
355
+ *
356
+ * ```js
357
+ * const myURL = new URL('https://example.org/foo/bar?baz');
358
+ * console.log(myURL.origin);
359
+ * // Prints https://example.org
360
+ * ```
361
+ *
362
+ * ```js
363
+ * const idnURL = new URL('https://測試');
364
+ * console.log(idnURL.origin);
365
+ * // Prints https://xn--g6w251d
366
+ *
367
+ * console.log(idnURL.hostname);
368
+ * // Prints xn--g6w251d
369
+ * ```
370
+ */
371
+ readonly origin: string;
372
+ /**
373
+ * Gets and sets the password portion of the URL.
374
+ *
375
+ * ```js
376
+ * const myURL = new URL('https://abc:xyz@example.com');
377
+ * console.log(myURL.password);
378
+ * // Prints xyz
379
+ *
380
+ * myURL.password = '123';
381
+ * console.log(myURL.href);
382
+ * // Prints https://abc:123@example.com/
383
+ * ```
384
+ *
385
+ * Invalid URL characters included in the value assigned to the `password` property
386
+ * are `percent-encoded`. The selection of which characters to
387
+ * percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
388
+ */
389
+ password: string;
390
+ /**
391
+ * Gets and sets the path portion of the URL.
392
+ *
393
+ * ```js
394
+ * const myURL = new URL('https://example.org/abc/xyz?123');
395
+ * console.log(myURL.pathname);
396
+ * // Prints /abc/xyz
397
+ *
398
+ * myURL.pathname = '/abcdef';
399
+ * console.log(myURL.href);
400
+ * // Prints https://example.org/abcdef?123
401
+ * ```
402
+ *
403
+ * Invalid URL characters included in the value assigned to the `pathname` property are `percent-encoded`. The selection of which characters
404
+ * to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
405
+ */
406
+ pathname: string;
407
+ /**
408
+ * Gets and sets the port portion of the URL.
409
+ *
410
+ * 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
411
+ * result in the `port` value becoming
412
+ * the empty string (`''`).
413
+ *
414
+ * The port value can be an empty string in which case the port depends on
415
+ * the protocol/scheme:
416
+ *
417
+ * <omitted>
418
+ *
419
+ * Upon assigning a value to the port, the value will first be converted to a
420
+ * string using `.toString()`.
421
+ *
422
+ * If that string is invalid but it begins with a number, the leading number is
423
+ * assigned to `port`.
424
+ * If the number lies outside the range denoted above, it is ignored.
425
+ *
426
+ * ```js
427
+ * const myURL = new URL('https://example.org:8888');
428
+ * console.log(myURL.port);
429
+ * // Prints 8888
430
+ *
431
+ * // Default ports are automatically transformed to the empty string
432
+ * // (HTTPS protocol's default port is 443)
433
+ * myURL.port = '443';
434
+ * console.log(myURL.port);
435
+ * // Prints the empty string
436
+ * console.log(myURL.href);
437
+ * // Prints https://example.org/
438
+ *
439
+ * myURL.port = 1234;
440
+ * console.log(myURL.port);
441
+ * // Prints 1234
442
+ * console.log(myURL.href);
443
+ * // Prints https://example.org:1234/
444
+ *
445
+ * // Completely invalid port strings are ignored
446
+ * myURL.port = 'abcd';
447
+ * console.log(myURL.port);
448
+ * // Prints 1234
449
+ *
450
+ * // Leading numbers are treated as a port number
451
+ * myURL.port = '5678abcd';
452
+ * console.log(myURL.port);
453
+ * // Prints 5678
454
+ *
455
+ * // Non-integers are truncated
456
+ * myURL.port = 1234.5678;
457
+ * console.log(myURL.port);
458
+ * // Prints 1234
459
+ *
460
+ * // Out-of-range numbers which are not represented in scientific notation
461
+ * // will be ignored.
462
+ * myURL.port = 1e10; // 10000000000, will be range-checked as described below
463
+ * console.log(myURL.port);
464
+ * // Prints 1234
465
+ * ```
466
+ *
467
+ * Numbers which contain a decimal point,
468
+ * such as floating-point numbers or numbers in scientific notation,
469
+ * are not an exception to this rule.
470
+ * Leading numbers up to the decimal point will be set as the URL's port,
471
+ * assuming they are valid:
472
+ *
473
+ * ```js
474
+ * myURL.port = 4.567e21;
475
+ * console.log(myURL.port);
476
+ * // Prints 4 (because it is the leading number in the string '4.567e21')
477
+ * ```
478
+ */
479
+ port: string;
480
+ /**
481
+ * Gets and sets the protocol portion of the URL.
482
+ *
483
+ * ```js
484
+ * const myURL = new URL('https://example.org');
485
+ * console.log(myURL.protocol);
486
+ * // Prints https:
487
+ *
488
+ * myURL.protocol = 'ftp';
489
+ * console.log(myURL.href);
490
+ * // Prints ftp://example.org/
491
+ * ```
492
+ *
493
+ * Invalid URL protocol values assigned to the `protocol` property are ignored.
494
+ */
495
+ protocol: string;
496
+ /**
497
+ * Gets and sets the serialized query portion of the URL.
498
+ *
499
+ * ```js
500
+ * const myURL = new URL('https://example.org/abc?123');
501
+ * console.log(myURL.search);
502
+ * // Prints ?123
503
+ *
504
+ * myURL.search = 'abc=xyz';
505
+ * console.log(myURL.href);
506
+ * // Prints https://example.org/abc?abc=xyz
507
+ * ```
508
+ *
509
+ * Any invalid URL characters appearing in the value assigned the `search` property will be `percent-encoded`. The selection of which
510
+ * characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
511
+ */
512
+ search: string;
513
+ /**
514
+ * Gets the `URLSearchParams` object representing the query parameters of the
515
+ * URL. This property is read-only but the `URLSearchParams` object it provides
516
+ * can be used to mutate the URL instance; to replace the entirety of query
517
+ * parameters of the URL, use the {@link search} setter. See `URLSearchParams` documentation for details.
518
+ *
519
+ * Use care when using `.searchParams` to modify the `URL` because,
520
+ * per the WHATWG specification, the `URLSearchParams` object uses
521
+ * different rules to determine which characters to percent-encode. For
522
+ * instance, the `URL` object will not percent encode the ASCII tilde (`~`)
523
+ * character, while `URLSearchParams` will always encode it:
524
+ *
525
+ * ```js
526
+ * const myURL = new URL('https://example.org/abc?foo=~bar');
527
+ *
528
+ * console.log(myURL.search); // prints ?foo=~bar
529
+ *
530
+ * // Modify the URL via searchParams...
531
+ * myURL.searchParams.sort();
532
+ *
533
+ * console.log(myURL.search); // prints ?foo=%7Ebar
534
+ * ```
535
+ */
536
+ readonly searchParams: URLSearchParams;
537
+ /**
538
+ * Gets and sets the username portion of the URL.
539
+ *
540
+ * ```js
541
+ * const myURL = new URL('https://abc:xyz@example.com');
542
+ * console.log(myURL.username);
543
+ * // Prints abc
544
+ *
545
+ * myURL.username = '123';
546
+ * console.log(myURL.href);
547
+ * // Prints https://123:xyz@example.com/
548
+ * ```
549
+ *
550
+ * Any invalid URL characters appearing in the value assigned the `username` property will be `percent-encoded`. The selection of which
551
+ * characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce.
552
+ */
553
+ username: string;
554
+ /**
555
+ * The `toString()` method on the `URL` object returns the serialized URL. The
556
+ * value returned is equivalent to that of {@link href} and {@link toJSON}.
557
+ */
558
+ toString(): string;
559
+ /**
560
+ * The `toJSON()` method on the `URL` object returns the serialized URL. The
561
+ * value returned is equivalent to that of {@link href} and {@link toString}.
562
+ *
563
+ * This method is automatically called when an `URL` object is serialized
564
+ * with [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify).
565
+ *
566
+ * ```js
567
+ * const myURLs = [
568
+ * new URL('https://www.example.com'),
569
+ * new URL('https://test.example.org'),
570
+ * ];
571
+ * console.log(JSON.stringify(myURLs));
572
+ * // Prints ["https://www.example.com/","https://test.example.org/"]
573
+ * ```
574
+ */
575
+ toJSON(): string;
576
+ }
577
+ /**
578
+ * 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
579
+ * four following constructors.
580
+ * The `URLSearchParams` class is also available on the global object.
581
+ *
582
+ * The WHATWG `URLSearchParams` interface and the `querystring` module have
583
+ * similar purpose, but the purpose of the `querystring` module is more
584
+ * general, as it allows the customization of delimiter characters (`&#x26;` and `=`).
585
+ * On the other hand, this API is designed purely for URL query strings.
586
+ *
587
+ * ```js
588
+ * const myURL = new URL('https://example.org/?abc=123');
589
+ * console.log(myURL.searchParams.get('abc'));
590
+ * // Prints 123
591
+ *
592
+ * myURL.searchParams.append('abc', 'xyz');
593
+ * console.log(myURL.href);
594
+ * // Prints https://example.org/?abc=123&#x26;abc=xyz
595
+ *
596
+ * myURL.searchParams.delete('abc');
597
+ * myURL.searchParams.set('a', 'b');
598
+ * console.log(myURL.href);
599
+ * // Prints https://example.org/?a=b
600
+ *
601
+ * const newSearchParams = new URLSearchParams(myURL.searchParams);
602
+ * // The above is equivalent to
603
+ * // const newSearchParams = new URLSearchParams(myURL.search);
604
+ *
605
+ * newSearchParams.append('a', 'c');
606
+ * console.log(myURL.href);
607
+ * // Prints https://example.org/?a=b
608
+ * console.log(newSearchParams.toString());
609
+ * // Prints a=b&#x26;a=c
610
+ *
611
+ * // newSearchParams.toString() is implicitly called
612
+ * myURL.search = newSearchParams;
613
+ * console.log(myURL.href);
614
+ * // Prints https://example.org/?a=b&#x26;a=c
615
+ * newSearchParams.delete('a');
616
+ * console.log(myURL.href);
617
+ * // Prints https://example.org/?a=b&#x26;a=c
618
+ * ```
619
+ */
620
+ class URLSearchParams implements Iterable<[string, string]> {
621
+ constructor(
622
+ init?:
623
+ | URLSearchParams
624
+ | string
625
+ | Record<string, string | readonly string[]>
626
+ | Iterable<[string, string]>
627
+ | ReadonlyArray<[string, string]>
628
+ );
629
+ /**
630
+ * Append a new name-value pair to the query string.
631
+ */
632
+ append(name: string, value: string): void;
633
+ /**
634
+ * If `value` is provided, removes all name-value pairs
635
+ * where name is `name` and value is `value`.
636
+ *
637
+ * If `value` is not provided, removes all name-value pairs whose name is `name`.
638
+ */
639
+ delete(name: string, value?: string): void;
640
+ /**
641
+ * Returns an ES6 `Iterator` over each of the name-value pairs in the query.
642
+ * 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`.
643
+ *
644
+ * Alias for `urlSearchParams[@@iterator]()`.
645
+ */
646
+ entries(): IterableIterator<[string, string]>;
647
+ /**
648
+ * Iterates over each name-value pair in the query and invokes the given function.
649
+ *
650
+ * ```js
651
+ * const myURL = new URL('https://example.org/?a=b&#x26;c=d');
652
+ * myURL.searchParams.forEach((value, name, searchParams) => {
653
+ * console.log(name, value, myURL.searchParams === searchParams);
654
+ * });
655
+ * // Prints:
656
+ * // a b true
657
+ * // c d true
658
+ * ```
659
+ * @param fn Invoked for each name-value pair in the query
660
+ * @param thisArg To be used as `this` value for when `fn` is called
661
+ */
662
+ forEach<TThis = this>(
663
+ fn: (
664
+ this: TThis,
665
+ value: string,
666
+ name: string,
667
+ searchParams: URLSearchParams
668
+ ) => void,
669
+ thisArg?: TThis
670
+ ): void;
671
+ /**
672
+ * Returns the value of the first name-value pair whose name is `name`. If there
673
+ * are no such pairs, `null` is returned.
674
+ * @return or `null` if there is no name-value pair with the given `name`.
675
+ */
676
+ get(name: string): string | null;
677
+ /**
678
+ * Checks if the `URLSearchParams` object contains key-value pair(s) based on `name` and an optional `value` argument.
679
+ *
680
+ * If `value` is provided, returns `true` when name-value pair with
681
+ * same `name` and `value` exists.
682
+ *
683
+ * If `value` is not provided, returns `true` if there is at least one name-value
684
+ * pair whose name is `name`.
685
+ */
686
+ has(name: string, value?: string): boolean;
687
+ /**
688
+ * Returns an ES6 `Iterator` over the names of each name-value pair.
689
+ *
690
+ * ```js
691
+ * const params = new URLSearchParams('foo=bar&#x26;foo=baz');
692
+ * for (const name of params.keys()) {
693
+ * console.log(name);
694
+ * }
695
+ * // Prints:
696
+ * // foo
697
+ * // foo
698
+ * ```
699
+ */
700
+ keys(): IterableIterator<string>;
701
+ /**
702
+ * Sets the value in the `URLSearchParams` object associated with `name` to `value`. If there are any pre-existing name-value pairs whose names are `name`,
703
+ * set the first such pair's value to `value` and remove all others. If not,
704
+ * append the name-value pair to the query string.
705
+ *
706
+ * ```js
707
+ * const params = new URLSearchParams();
708
+ * params.append('foo', 'bar');
709
+ * params.append('foo', 'baz');
710
+ * params.append('abc', 'def');
711
+ * console.log(params.toString());
712
+ * // Prints foo=bar&#x26;foo=baz&#x26;abc=def
713
+ *
714
+ * params.set('foo', 'def');
715
+ * params.set('xyz', 'opq');
716
+ * console.log(params.toString());
717
+ * // Prints foo=def&#x26;abc=def&#x26;xyz=opq
718
+ * ```
719
+ */
720
+ set(name: string, value: string): void;
721
+ /**
722
+ * Sort all existing name-value pairs in-place by their names. Sorting is done
723
+ * with a [stable sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability), so relative order between name-value pairs
724
+ * with the same name is preserved.
725
+ *
726
+ * This method can be used, in particular, to increase cache hits.
727
+ *
728
+ * ```js
729
+ * const params = new URLSearchParams('query[]=abc&#x26;type=search&#x26;query[]=123');
730
+ * params.sort();
731
+ * console.log(params.toString());
732
+ * // Prints query%5B%5D=abc&#x26;query%5B%5D=123&#x26;type=search
733
+ * ```
734
+ */
735
+ sort(): void;
736
+ /**
737
+ * Returns the search parameters serialized as a string, with characters
738
+ * percent-encoded where necessary.
739
+ */
740
+ toString(): string;
741
+ /**
742
+ * Returns an ES6 `Iterator` over the values of each name-value pair.
743
+ */
744
+ values(): IterableIterator<string>;
745
+ [Symbol.iterator](): IterableIterator<[string, string]>;
746
+ }
747
+ import { URL as _URL, URLSearchParams as _URLSearchParams } from "url";
748
+ global {
749
+ interface URLSearchParams extends _URLSearchParams {}
750
+ interface URL extends _URL {}
751
+ interface Global {
752
+ URL: typeof _URL;
753
+ URLSearchParams: typeof _URLSearchParams;
754
+ }
755
+ /**
756
+ * `URL` class is a global reference for `require('url').URL`
757
+ */
758
+ var URL: typeof globalThis extends {
759
+ onmessage: any;
760
+ URL: infer T;
761
+ }
762
+ ? T
763
+ : typeof _URL;
764
+ /**
765
+ * `URLSearchParams` class is a global reference for `require('url').URLSearchParams`
766
+ */
767
+ var URLSearchParams: typeof globalThis extends {
768
+ onmessage: any;
769
+ URLSearchParams: infer T;
770
+ }
771
+ ? T
772
+ : typeof _URLSearchParams;
773
+ }
774
+ }