@types/node 18.16.2 → 20.0.0

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 (95) hide show
  1. node/README.md +1 -1
  2. node/assert.d.ts +68 -73
  3. node/async_hooks.d.ts +62 -42
  4. node/buffer.d.ts +123 -95
  5. node/child_process.d.ts +50 -54
  6. node/cluster.d.ts +12 -12
  7. node/console.d.ts +5 -5
  8. node/crypto.d.ts +209 -220
  9. node/dgram.d.ts +15 -15
  10. node/diagnostics_channel.d.ts +25 -26
  11. node/dns/promises.d.ts +6 -6
  12. node/dns.d.ts +16 -16
  13. node/domain.d.ts +3 -3
  14. node/events.d.ts +60 -60
  15. node/fs/promises.d.ts +74 -48
  16. node/fs.d.ts +91 -81
  17. node/http.d.ts +147 -144
  18. node/http2.d.ts +42 -46
  19. node/https.d.ts +52 -153
  20. node/index.d.ts +1 -1
  21. node/inspector.d.ts +10 -3
  22. node/module.d.ts +5 -4
  23. node/net.d.ts +21 -18
  24. node/os.d.ts +22 -18
  25. node/package.json +2 -2
  26. node/path.d.ts +4 -4
  27. node/perf_hooks.d.ts +28 -15
  28. node/process.d.ts +43 -46
  29. node/punycode.d.ts +1 -1
  30. node/querystring.d.ts +5 -5
  31. node/readline/promises.d.ts +6 -4
  32. node/readline.d.ts +15 -15
  33. node/repl.d.ts +9 -9
  34. node/stream/consumers.d.ts +1 -1
  35. node/stream.d.ts +74 -136
  36. node/string_decoder.d.ts +6 -6
  37. node/test.d.ts +0 -76
  38. node/timers/promises.d.ts +3 -3
  39. node/timers.d.ts +2 -2
  40. node/tls.d.ts +29 -15
  41. node/trace_events.d.ts +20 -9
  42. node/ts4.8/assert.d.ts +68 -73
  43. node/ts4.8/async_hooks.d.ts +59 -31
  44. node/ts4.8/buffer.d.ts +123 -95
  45. node/ts4.8/child_process.d.ts +50 -54
  46. node/ts4.8/cluster.d.ts +12 -12
  47. node/ts4.8/console.d.ts +5 -5
  48. node/ts4.8/crypto.d.ts +209 -220
  49. node/ts4.8/dgram.d.ts +15 -15
  50. node/ts4.8/diagnostics_channel.d.ts +25 -26
  51. node/ts4.8/dns/promises.d.ts +6 -6
  52. node/ts4.8/dns.d.ts +16 -16
  53. node/ts4.8/domain.d.ts +3 -3
  54. node/ts4.8/events.d.ts +60 -60
  55. node/ts4.8/fs/promises.d.ts +72 -45
  56. node/ts4.8/fs.d.ts +81 -67
  57. node/ts4.8/http.d.ts +133 -126
  58. node/ts4.8/http2.d.ts +42 -46
  59. node/ts4.8/https.d.ts +52 -153
  60. node/ts4.8/inspector.d.ts +10 -3
  61. node/ts4.8/module.d.ts +5 -4
  62. node/ts4.8/net.d.ts +21 -18
  63. node/ts4.8/os.d.ts +22 -18
  64. node/ts4.8/path.d.ts +4 -4
  65. node/ts4.8/perf_hooks.d.ts +28 -15
  66. node/ts4.8/process.d.ts +43 -46
  67. node/ts4.8/punycode.d.ts +1 -1
  68. node/ts4.8/querystring.d.ts +5 -5
  69. node/ts4.8/readline/promises.d.ts +6 -4
  70. node/ts4.8/readline.d.ts +15 -15
  71. node/ts4.8/repl.d.ts +9 -9
  72. node/ts4.8/stream/consumers.d.ts +1 -1
  73. node/ts4.8/stream.d.ts +77 -139
  74. node/ts4.8/string_decoder.d.ts +6 -6
  75. node/ts4.8/test.d.ts +0 -75
  76. node/ts4.8/timers/promises.d.ts +3 -3
  77. node/ts4.8/timers.d.ts +2 -2
  78. node/ts4.8/tls.d.ts +29 -15
  79. node/ts4.8/trace_events.d.ts +20 -9
  80. node/ts4.8/tty.d.ts +4 -5
  81. node/ts4.8/url.d.ts +26 -36
  82. node/ts4.8/util.d.ts +143 -116
  83. node/ts4.8/v8.d.ts +107 -16
  84. node/ts4.8/vm.d.ts +292 -42
  85. node/ts4.8/wasi.d.ts +8 -14
  86. node/ts4.8/worker_threads.d.ts +32 -34
  87. node/ts4.8/zlib.d.ts +11 -11
  88. node/tty.d.ts +4 -5
  89. node/url.d.ts +26 -36
  90. node/util.d.ts +146 -111
  91. node/v8.d.ts +110 -16
  92. node/vm.d.ts +292 -42
  93. node/wasi.d.ts +8 -14
  94. node/worker_threads.d.ts +32 -34
  95. node/zlib.d.ts +11 -11
node/ts4.8/util.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
- * The `util` module supports the needs of Node.js internal APIs. Many of the
2
+ * The `node:util` module supports the needs of Node.js internal APIs. Many of the
3
3
  * utilities are useful for application and module developers as well. To access
4
4
  * it:
5
5
  *
6
6
  * ```js
7
- * const util = require('util');
7
+ * const util = require('node:util');
8
8
  * ```
9
- * @see [source](https://github.com/nodejs/node/blob/v18.x/lib/util.js)
9
+ * @see [source](https://github.com/nodejs/node/blob/v20.0.0/lib/util.js)
10
10
  */
11
11
  declare module 'util' {
12
12
  import * as types from 'node:util/types';
@@ -189,7 +189,7 @@ declare module 'util' {
189
189
  * timestamp.
190
190
  *
191
191
  * ```js
192
- * const util = require('util');
192
+ * const util = require('node:util');
193
193
  *
194
194
  * util.log('Timestamped message.');
195
195
  * ```
@@ -208,12 +208,12 @@ declare module 'util' {
208
208
  * Creates and returns an `AbortController` instance whose `AbortSignal` is marked
209
209
  * as transferable and can be used with `structuredClone()` or `postMessage()`.
210
210
  * @since v18.11.0
211
+ * @experimental
211
212
  * @returns A transferable AbortController
212
213
  */
213
214
  export function transferableAbortController(): AbortController;
214
215
  /**
215
- * Marks the given {AbortSignal} as transferable so that it can be used with
216
- * `structuredClone()` and `postMessage()`.
216
+ * Marks the given `AbortSignal` as transferable so that it can be used with`structuredClone()` and `postMessage()`.
217
217
  *
218
218
  * ```js
219
219
  * const signal = transferableAbortSignal(AbortSignal.timeout(100));
@@ -221,14 +221,33 @@ declare module 'util' {
221
221
  * channel.port2.postMessage(signal, [signal]);
222
222
  * ```
223
223
  * @since v18.11.0
224
+ * @experimental
224
225
  * @param signal The AbortSignal
225
226
  * @returns The same AbortSignal
226
227
  */
227
228
  export function transferableAbortSignal(signal: AbortSignal): AbortSignal;
228
229
  /**
229
- * Listens to abort event on the provided `signal` and returns a promise that is fulfilled when the `signal` is aborted.
230
- * If the passed `resource` is garbage collected before the `signal` is aborted, the returned promise shall remain pending indefinitely.
231
- * @param resource Any non-null entity, reference to which is held weakly.
230
+ * Listens to abort event on the provided `signal` and
231
+ * returns a promise that is fulfilled when the `signal` is
232
+ * aborted. If the passed `resource` is garbage collected before the `signal` is
233
+ * aborted, the returned promise shall remain pending indefinitely.
234
+ *
235
+ * ```js
236
+ * import { aborted } from 'node:util';
237
+ *
238
+ * const dependent = obtainSomethingAbortable();
239
+ *
240
+ * aborted(dependent.signal, dependent).then(() => {
241
+ * // Do something when dependent is aborted.
242
+ * });
243
+ *
244
+ * dependent.on('event', () => {
245
+ * dependent.abort();
246
+ * });
247
+ * ```
248
+ * @since v19.7.0
249
+ * @experimental
250
+ * @param resource Any non-null entity, reference to which is held weakly.
232
251
  */
233
252
  export function aborted(signal: AbortSignal, resource: any): Promise<void>;
234
253
  /**
@@ -257,7 +276,7 @@ declare module 'util' {
257
276
  * Circular references point to their anchor by using a reference index:
258
277
  *
259
278
  * ```js
260
- * const { inspect } = require('util');
279
+ * const { inspect } = require('node:util');
261
280
  *
262
281
  * const obj = {};
263
282
  * obj.a = [obj];
@@ -275,7 +294,7 @@ declare module 'util' {
275
294
  * The following example inspects all properties of the `util` object:
276
295
  *
277
296
  * ```js
278
- * const util = require('util');
297
+ * const util = require('node:util');
279
298
  *
280
299
  * console.log(util.inspect(util, { showHidden: true, depth: null }));
281
300
  * ```
@@ -283,7 +302,7 @@ declare module 'util' {
283
302
  * The following example highlights the effect of the `compact` option:
284
303
  *
285
304
  * ```js
286
- * const util = require('util');
305
+ * const util = require('node:util');
287
306
  *
288
307
  * const o = {
289
308
  * a: [1, 2, [[
@@ -291,7 +310,7 @@ declare module 'util' {
291
310
  * 'eiusmod \ntempor incididunt ut labore et dolore magna aliqua.',
292
311
  * 'test',
293
312
  * 'foo']], 4],
294
- * b: new Map([['za', 1], ['zb', 'test']])
313
+ * b: new Map([['za', 1], ['zb', 'test']]),
295
314
  * };
296
315
  * console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 }));
297
316
  *
@@ -340,7 +359,7 @@ declare module 'util' {
340
359
  * with no remaining strong references may be garbage collected at any time.
341
360
  *
342
361
  * ```js
343
- * const { inspect } = require('util');
362
+ * const { inspect } = require('node:util');
344
363
  *
345
364
  * const obj = { a: 1 };
346
365
  * const obj2 = { b: 2 };
@@ -354,13 +373,13 @@ declare module 'util' {
354
373
  * impact the result of `util.inspect()`.
355
374
  *
356
375
  * ```js
357
- * const { inspect } = require('util');
358
- * const assert = require('assert');
376
+ * const { inspect } = require('node:util');
377
+ * const assert = require('node:assert');
359
378
  *
360
379
  * const o1 = {
361
380
  * b: [2, 3, 1],
362
381
  * a: '`a` comes before `b`',
363
- * c: new Set([2, 3, 1])
382
+ * c: new Set([2, 3, 1]),
364
383
  * };
365
384
  * console.log(inspect(o1, { sorted: true }));
366
385
  * // { a: '`a` comes before `b`', b: [ 2, 3, 1 ], c: Set(3) { 1, 2, 3 } }
@@ -370,11 +389,11 @@ declare module 'util' {
370
389
  * const o2 = {
371
390
  * c: new Set([2, 1, 3]),
372
391
  * a: '`a` comes before `b`',
373
- * b: [2, 3, 1]
392
+ * b: [2, 3, 1],
374
393
  * };
375
394
  * assert.strict.equal(
376
395
  * inspect(o1, { sorted: true }),
377
- * inspect(o2, { sorted: true })
396
+ * inspect(o2, { sorted: true }),
378
397
  * );
379
398
  * ```
380
399
  *
@@ -382,7 +401,7 @@ declare module 'util' {
382
401
  * numbers.
383
402
  *
384
403
  * ```js
385
- * const { inspect } = require('util');
404
+ * const { inspect } = require('node:util');
386
405
  *
387
406
  * const thousand = 1_000;
388
407
  * const million = 1_000_000;
@@ -394,7 +413,7 @@ declare module 'util' {
394
413
  * ```
395
414
  *
396
415
  * `util.inspect()` is a synchronous method intended for debugging. Its maximum
397
- * output length is approximately 128 MB. Inputs that result in longer output will
416
+ * output length is approximately 128 MiB. Inputs that result in longer output will
398
417
  * be truncated.
399
418
  * @since v0.3.0
400
419
  * @param object Any JavaScript primitive or `Object`.
@@ -423,7 +442,7 @@ declare module 'util' {
423
442
  * Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`.
424
443
  *
425
444
  * ```js
426
- * const util = require('util');
445
+ * const util = require('node:util');
427
446
  *
428
447
  * util.isArray([]);
429
448
  * // Returns: true
@@ -440,7 +459,7 @@ declare module 'util' {
440
459
  * Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`.
441
460
  *
442
461
  * ```js
443
- * const util = require('util');
462
+ * const util = require('node:util');
444
463
  *
445
464
  * util.isRegExp(/some regexp/);
446
465
  * // Returns: true
@@ -457,7 +476,7 @@ declare module 'util' {
457
476
  * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
458
477
  *
459
478
  * ```js
460
- * const util = require('util');
479
+ * const util = require('node:util');
461
480
  *
462
481
  * util.isDate(new Date());
463
482
  * // Returns: true
@@ -474,7 +493,7 @@ declare module 'util' {
474
493
  * Returns `true` if the given `object` is an `Error`. Otherwise, returns`false`.
475
494
  *
476
495
  * ```js
477
- * const util = require('util');
496
+ * const util = require('node:util');
478
497
  *
479
498
  * util.isError(new Error());
480
499
  * // Returns: true
@@ -488,7 +507,7 @@ declare module 'util' {
488
507
  * possible to obtain an incorrect result when the `object` argument manipulates`@@toStringTag`.
489
508
  *
490
509
  * ```js
491
- * const util = require('util');
510
+ * const util = require('node:util');
492
511
  * const obj = { name: 'Error', message: 'an error occurred' };
493
512
  *
494
513
  * util.isError(obj);
@@ -513,8 +532,8 @@ declare module 'util' {
513
532
  * through the `constructor.super_` property.
514
533
  *
515
534
  * ```js
516
- * const util = require('util');
517
- * const EventEmitter = require('events');
535
+ * const util = require('node:util');
536
+ * const EventEmitter = require('node:events');
518
537
  *
519
538
  * function MyStream() {
520
539
  * EventEmitter.call(this);
@@ -540,7 +559,7 @@ declare module 'util' {
540
559
  * ES6 example using `class` and `extends`:
541
560
  *
542
561
  * ```js
543
- * const EventEmitter = require('events');
562
+ * const EventEmitter = require('node:events');
544
563
  *
545
564
  * class MyStream extends EventEmitter {
546
565
  * write(data) {
@@ -569,7 +588,7 @@ declare module 'util' {
569
588
  * environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op.
570
589
  *
571
590
  * ```js
572
- * const util = require('util');
591
+ * const util = require('node:util');
573
592
  * const debuglog = util.debuglog('foo');
574
593
  *
575
594
  * debuglog('hello from foo [%d]', 123);
@@ -588,7 +607,7 @@ declare module 'util' {
588
607
  * The `section` supports wildcard also:
589
608
  *
590
609
  * ```js
591
- * const util = require('util');
610
+ * const util = require('node:util');
592
611
  * const debuglog = util.debuglog('foo-bar');
593
612
  *
594
613
  * debuglog('hi there, it\'s foo-bar [%d]', 2333);
@@ -608,7 +627,7 @@ declare module 'util' {
608
627
  * unnecessary wrapping.
609
628
  *
610
629
  * ```js
611
- * const util = require('util');
630
+ * const util = require('node:util');
612
631
  * let debuglog = util.debuglog('internals', (debug) => {
613
632
  * // Replace with a logging function that optimizes out
614
633
  * // testing if the section is enabled
@@ -626,7 +645,7 @@ declare module 'util' {
626
645
  * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
627
646
  *
628
647
  * ```js
629
- * const util = require('util');
648
+ * const util = require('node:util');
630
649
  *
631
650
  * util.isBoolean(1);
632
651
  * // Returns: false
@@ -643,7 +662,7 @@ declare module 'util' {
643
662
  * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`.
644
663
  *
645
664
  * ```js
646
- * const util = require('util');
665
+ * const util = require('node:util');
647
666
  *
648
667
  * util.isBuffer({ length: 0 });
649
668
  * // Returns: false
@@ -660,7 +679,7 @@ declare module 'util' {
660
679
  * Returns `true` if the given `object` is a `Function`. Otherwise, returns`false`.
661
680
  *
662
681
  * ```js
663
- * const util = require('util');
682
+ * const util = require('node:util');
664
683
  *
665
684
  * function Foo() {}
666
685
  * const Bar = () => {};
@@ -680,7 +699,7 @@ declare module 'util' {
680
699
  * Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`.
681
700
  *
682
701
  * ```js
683
- * const util = require('util');
702
+ * const util = require('node:util');
684
703
  *
685
704
  * util.isNull(0);
686
705
  * // Returns: false
@@ -698,7 +717,7 @@ declare module 'util' {
698
717
  * returns `false`.
699
718
  *
700
719
  * ```js
701
- * const util = require('util');
720
+ * const util = require('node:util');
702
721
  *
703
722
  * util.isNullOrUndefined(0);
704
723
  * // Returns: false
@@ -715,7 +734,7 @@ declare module 'util' {
715
734
  * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.
716
735
  *
717
736
  * ```js
718
- * const util = require('util');
737
+ * const util = require('node:util');
719
738
  *
720
739
  * util.isNumber(false);
721
740
  * // Returns: false
@@ -735,7 +754,7 @@ declare module 'util' {
735
754
  * Otherwise, returns `false`.
736
755
  *
737
756
  * ```js
738
- * const util = require('util');
757
+ * const util = require('node:util');
739
758
  *
740
759
  * util.isObject(5);
741
760
  * // Returns: false
@@ -747,14 +766,14 @@ declare module 'util' {
747
766
  * // Returns: false
748
767
  * ```
749
768
  * @since v0.11.5
750
- * @deprecated Since v4.0.0 - Deprecated: Use `value !== null && typeof value === 'object'` instead.
769
+ * @deprecated Since v4.0.0 - Use `value !== null && typeof value === 'object'` instead.
751
770
  */
752
771
  export function isObject(object: unknown): boolean;
753
772
  /**
754
773
  * Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`.
755
774
  *
756
775
  * ```js
757
- * const util = require('util');
776
+ * const util = require('node:util');
758
777
  *
759
778
  * util.isPrimitive(5);
760
779
  * // Returns: true
@@ -783,7 +802,7 @@ declare module 'util' {
783
802
  * Returns `true` if the given `object` is a `string`. Otherwise, returns `false`.
784
803
  *
785
804
  * ```js
786
- * const util = require('util');
805
+ * const util = require('node:util');
787
806
  *
788
807
  * util.isString('');
789
808
  * // Returns: true
@@ -802,7 +821,7 @@ declare module 'util' {
802
821
  * Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`.
803
822
  *
804
823
  * ```js
805
- * const util = require('util');
824
+ * const util = require('node:util');
806
825
  *
807
826
  * util.isSymbol(5);
808
827
  * // Returns: false
@@ -819,7 +838,7 @@ declare module 'util' {
819
838
  * Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`.
820
839
  *
821
840
  * ```js
822
- * const util = require('util');
841
+ * const util = require('node:util');
823
842
  *
824
843
  * const foo = undefined;
825
844
  * util.isUndefined(5);
@@ -838,7 +857,7 @@ declare module 'util' {
838
857
  * such a way that it is marked as deprecated.
839
858
  *
840
859
  * ```js
841
- * const util = require('util');
860
+ * const util = require('node:util');
842
861
  *
843
862
  * exports.obsoleteFunction = util.deprecate(() => {
844
863
  * // Do something here.
@@ -854,7 +873,7 @@ declare module 'util' {
854
873
  * the warning will be emitted only once for that `code`.
855
874
  *
856
875
  * ```js
857
- * const util = require('util');
876
+ * const util = require('node:util');
858
877
  *
859
878
  * const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001');
860
879
  * const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001');
@@ -908,7 +927,7 @@ declare module 'util' {
908
927
  * first argument will be the rejection reason (or `null` if the `Promise`resolved), and the second argument will be the resolved value.
909
928
  *
910
929
  * ```js
911
- * const util = require('util');
930
+ * const util = require('node:util');
912
931
  *
913
932
  * async function fn() {
914
933
  * return 'hello world';
@@ -991,8 +1010,8 @@ declare module 'util' {
991
1010
  * that returns promises.
992
1011
  *
993
1012
  * ```js
994
- * const util = require('util');
995
- * const fs = require('fs');
1013
+ * const util = require('node:util');
1014
+ * const fs = require('node:fs');
996
1015
  *
997
1016
  * const stat = util.promisify(fs.stat);
998
1017
  * stat('.').then((stats) => {
@@ -1005,8 +1024,8 @@ declare module 'util' {
1005
1024
  * Or, equivalently using `async function`s:
1006
1025
  *
1007
1026
  * ```js
1008
- * const util = require('util');
1009
- * const fs = require('fs');
1027
+ * const util = require('node:util');
1028
+ * const fs = require('node:fs');
1010
1029
  *
1011
1030
  * const stat = util.promisify(fs.stat);
1012
1031
  *
@@ -1027,7 +1046,7 @@ declare module 'util' {
1027
1046
  * work as expected unless handled specially:
1028
1047
  *
1029
1048
  * ```js
1030
- * const util = require('util');
1049
+ * const util = require('node:util');
1031
1050
  *
1032
1051
  * class Foo {
1033
1052
  * constructor() {
@@ -1116,7 +1135,7 @@ declare module 'util' {
1116
1135
  * internally and emitted after the next call to `textDecoder.decode()`.
1117
1136
  *
1118
1137
  * If `textDecoder.fatal` is `true`, decoding errors that occur will result in a`TypeError` being thrown.
1119
- * @param input An `ArrayBuffer`, `DataView` or `TypedArray` instance containing the encoded data.
1138
+ * @param input An `ArrayBuffer`, `DataView`, or `TypedArray` instance containing the encoded data.
1120
1139
  */
1121
1140
  decode(
1122
1141
  input?: NodeJS.ArrayBufferView | ArrayBuffer | null,
@@ -1184,19 +1203,18 @@ declare module 'util' {
1184
1203
  * https://nodejs.org/api/globals.html#textdecoder
1185
1204
  * @since v11.0.0
1186
1205
  */
1187
- var TextDecoder: typeof globalThis extends {
1206
+ var TextDecoder: typeof globalThis extends {
1188
1207
  onmessage: any;
1189
1208
  TextDecoder: infer TextDecoder;
1190
1209
  }
1191
1210
  ? TextDecoder
1192
1211
  : typeof _TextDecoder;
1193
-
1194
1212
  /**
1195
1213
  * `TextEncoder` class is a global reference for `require('util').TextEncoder`
1196
1214
  * https://nodejs.org/api/globals.html#textencoder
1197
1215
  * @since v11.0.0
1198
1216
  */
1199
- var TextEncoder: typeof globalThis extends {
1217
+ var TextEncoder: typeof globalThis extends {
1200
1218
  onmessage: any;
1201
1219
  TextEncoder: infer TextEncoder;
1202
1220
  }
@@ -1206,48 +1224,34 @@ declare module 'util' {
1206
1224
 
1207
1225
  //// parseArgs
1208
1226
  /**
1209
- * Provides a high-level API for command-line argument parsing. Takes a
1210
- * specification for the expected arguments and returns a structured object
1211
- * with the parsed values and positionals.
1212
- *
1213
- * `config` provides arguments for parsing and configures the parser. It
1214
- * supports the following properties:
1215
- *
1216
- * - `args` The array of argument strings. **Default:** `process.argv` with
1217
- * `execPath` and `filename` removed.
1218
- * - `options` Arguments known to the parser. Keys of `options` are the long
1219
- * names of options and values are objects accepting the following properties:
1220
- *
1221
- * - `type` Type of argument, which must be either `boolean` (for options
1222
- * which do not take values) or `string` (for options which do).
1223
- * - `multiple` Whether this option can be provided multiple
1224
- * times. If `true`, all values will be collected in an array. If
1225
- * `false`, values for the option are last-wins. **Default:** `false`.
1226
- * - `short` A single character alias for the option.
1227
- * - `default` The default option value when it is not set by args. It
1228
- * must be of the same type as the `type` property. When `multiple`
1229
- * is `true`, it must be an array.
1230
- *
1231
- * - `strict`: Whether an error should be thrown when unknown arguments
1232
- * are encountered, or when arguments are passed that do not match the
1233
- * `type` configured in `options`. **Default:** `true`.
1234
- * - `allowPositionals`: Whether this command accepts positional arguments.
1235
- * **Default:** `false` if `strict` is `true`, otherwise `true`.
1236
- * - `tokens`: Whether tokens {boolean} Return the parsed tokens. This is useful
1237
- * for extending the built-in behavior, from adding additional checks through
1238
- * to reprocessing the tokens in different ways.
1239
- * **Default:** `false`.
1240
- *
1241
- * @returns The parsed command line arguments:
1242
- *
1243
- * - `values` A mapping of parsed option names with their string
1244
- * or boolean values.
1245
- * - `positionals` Positional arguments.
1246
- * - `tokens` Detailed parse information (only if `tokens` was specified).
1247
- *
1227
+ * Provides a higher level API for command-line argument parsing than interacting
1228
+ * with `process.argv` directly. Takes a specification for the expected arguments
1229
+ * and returns a structured object with the parsed options and positionals.
1230
+ *
1231
+ * ```js
1232
+ * import { parseArgs } from 'node:util';
1233
+ * const args = ['-f', '--bar', 'b'];
1234
+ * const options = {
1235
+ * foo: {
1236
+ * type: 'boolean',
1237
+ * short: 'f',
1238
+ * },
1239
+ * bar: {
1240
+ * type: 'string',
1241
+ * },
1242
+ * };
1243
+ * const {
1244
+ * values,
1245
+ * positionals,
1246
+ * } = parseArgs({ args, options });
1247
+ * console.log(values, positionals);
1248
+ * // Prints: [Object: null prototype] { foo: true, bar: 'b' } []
1249
+ * ```
1250
+ * @since v18.3.0, v16.17.0
1251
+ * @param config Used to provide arguments for parsing and to configure the parser. `config` supports the following properties:
1252
+ * @return The parsed command line arguments:
1248
1253
  */
1249
1254
  export function parseArgs<T extends ParseArgsConfig>(config?: T): ParsedResults<T>;
1250
-
1251
1255
  interface ParseArgsOptionConfig {
1252
1256
  /**
1253
1257
  * Type of argument.
@@ -1272,11 +1276,9 @@ declare module 'util' {
1272
1276
  */
1273
1277
  default?: string | boolean | string[] | boolean[] | undefined;
1274
1278
  }
1275
-
1276
1279
  interface ParseArgsOptionsConfig {
1277
1280
  [longOption: string]: ParseArgsOptionConfig;
1278
1281
  }
1279
-
1280
1282
  export interface ParseArgsConfig {
1281
1283
  /**
1282
1284
  * Array of argument strings.
@@ -1303,7 +1305,6 @@ declare module 'util' {
1303
1305
  */
1304
1306
  tokens?: boolean | undefined;
1305
1307
  }
1306
-
1307
1308
  /*
1308
1309
  IfDefaultsTrue and IfDefaultsFalse are helpers to handle default values for missing boolean properties.
1309
1310
  TypeScript does not have exact types for objects: https://github.com/microsoft/TypeScript/issues/12936
@@ -1381,19 +1382,15 @@ declare module 'util' {
1381
1382
  ? PreciseTokenForOptions<K & string, T['options'][K]>
1382
1383
  : OptionToken
1383
1384
  : never;
1384
-
1385
1385
  type ParsedOptionToken<T extends ParseArgsConfig> = IfDefaultsTrue<T['strict'], TokenForOptions<T>, OptionToken>;
1386
-
1387
1386
  type ParsedPositionalToken<T extends ParseArgsConfig> = IfDefaultsTrue<
1388
1387
  T['strict'],
1389
1388
  IfDefaultsFalse<T['allowPositionals'], { kind: 'positional'; index: number; value: string }, never>,
1390
1389
  IfDefaultsTrue<T['allowPositionals'], { kind: 'positional'; index: number; value: string }, never>
1391
1390
  >;
1392
-
1393
1391
  type ParsedTokens<T extends ParseArgsConfig> = Array<
1394
1392
  ParsedOptionToken<T> | ParsedPositionalToken<T> | { kind: 'option-terminator'; index: number }
1395
1393
  >;
1396
-
1397
1394
  type PreciseParsedResults<T extends ParseArgsConfig> = IfDefaultsFalse<
1398
1395
  T['tokens'],
1399
1396
  {
@@ -1406,7 +1403,6 @@ declare module 'util' {
1406
1403
  positionals: ParsedPositionals<T>;
1407
1404
  }
1408
1405
  >;
1409
-
1410
1406
  type OptionToken =
1411
1407
  | { kind: 'option'; index: number; name: string; rawName: string; value: string; inlineValue: boolean }
1412
1408
  | {
@@ -1417,7 +1413,6 @@ declare module 'util' {
1417
1413
  value: undefined;
1418
1414
  inlineValue: undefined;
1419
1415
  };
1420
-
1421
1416
  type Token =
1422
1417
  | OptionToken
1423
1418
  | { kind: 'positional'; index: number; value: string }
@@ -1432,9 +1427,18 @@ declare module 'util' {
1432
1427
  tokens?: Token[];
1433
1428
  }
1434
1429
  : PreciseParsedResults<T>;
1435
-
1436
1430
  /**
1437
- * @since v18.13.0
1431
+ * An implementation of [the MIMEType class](https://bmeck.github.io/node-proposal-mime-api/).
1432
+ *
1433
+ * In accordance with browser conventions, all properties of `MIMEType` objects
1434
+ * are implemented as getters and setters on the class prototype, rather than as
1435
+ * data properties on the object itself.
1436
+ *
1437
+ * A MIME string is a structured string containing multiple meaningful
1438
+ * components. When parsed, a `MIMEType` object is returned containing
1439
+ * properties for each of these components.
1440
+ * @since v19.1.0, v18.13.0
1441
+ * @experimental
1438
1442
  */
1439
1443
  export class MIMEType {
1440
1444
  /**
@@ -1450,24 +1454,20 @@ declare module 'util' {
1450
1454
  * Gets and sets the type portion of the MIME.
1451
1455
  */
1452
1456
  type: string;
1453
-
1454
1457
  /**
1455
1458
  * Gets and sets the subtype portion of the MIME.
1456
1459
  */
1457
1460
  subtype: string;
1458
-
1459
1461
  /**
1460
1462
  * Gets the essence of the MIME.
1461
1463
  *
1462
1464
  * Use `mime.type` or `mime.subtype` to alter the MIME.
1463
1465
  */
1464
1466
  readonly essence: string;
1465
-
1466
1467
  /**
1467
1468
  * Gets the `MIMEParams` object representing the parameters of the MIME.
1468
1469
  */
1469
1470
  readonly params: MIMEParams;
1470
-
1471
1471
  /**
1472
1472
  * Returns the serialized MIME.
1473
1473
  *
@@ -1476,7 +1476,6 @@ declare module 'util' {
1476
1476
  */
1477
1477
  toString(): string;
1478
1478
  }
1479
-
1480
1479
  /**
1481
1480
  * @since v18.13.0
1482
1481
  */
@@ -1814,12 +1813,40 @@ declare module 'util/types' {
1814
1813
  */
1815
1814
  function isModuleNamespaceObject(value: unknown): boolean;
1816
1815
  /**
1817
- * Returns `true` if the value is an instance of a built-in `Error` type.
1816
+ * Returns `true` if the value was returned by the constructor of a [built-in `Error` type](https://tc39.es/ecma262/#sec-error-objects).
1817
+ *
1818
+ * ```js
1819
+ * console.log(util.types.isNativeError(new Error())); // true
1820
+ * console.log(util.types.isNativeError(new TypeError())); // true
1821
+ * console.log(util.types.isNativeError(new RangeError())); // true
1822
+ * ```
1823
+ *
1824
+ * Subclasses of the native error types are also native errors:
1825
+ *
1826
+ * ```js
1827
+ * class MyError extends Error {}
1828
+ * console.log(util.types.isNativeError(new MyError())); // true
1829
+ * ```
1830
+ *
1831
+ * A value being `instanceof` a native error class is not equivalent to `isNativeError()`returning `true` for that value. `isNativeError()` returns `true` for errors
1832
+ * which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false`for these errors:
1833
+ *
1834
+ * ```js
1835
+ * const vm = require('node:vm');
1836
+ * const context = vm.createContext({});
1837
+ * const myError = vm.runInContext('new Error', context);
1838
+ * console.log(util.types.isNativeError(myError)); // true
1839
+ * console.log(myError instanceof Error); // false
1840
+ * ```
1841
+ *
1842
+ * Conversely, `isNativeError()` returns `false` for all objects which were not
1843
+ * returned by the constructor of a native error. That includes values
1844
+ * which are `instanceof` native errors:
1818
1845
  *
1819
1846
  * ```js
1820
- * util.types.isNativeError(new Error()); // Returns true
1821
- * util.types.isNativeError(new TypeError()); // Returns true
1822
- * util.types.isNativeError(new RangeError()); // Returns true
1847
+ * const myError = { __proto__: Error.prototype };
1848
+ * console.log(util.types.isNativeError(myError)); // false
1849
+ * console.log(myError instanceof Error); // true
1823
1850
  * ```
1824
1851
  * @since v10.0.0
1825
1852
  */