@idlebox/stripe-node-types 24.0.14-patch.0 → 24.0.15

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 (134) hide show
  1. package/README.md +1 -1
  2. package/assert/strict.d.ts +113 -1
  3. package/assert.d.ts +162 -248
  4. package/async_hooks.d.ts +20 -5
  5. package/buffer.buffer.d.ts +24 -6
  6. package/buffer.d.ts +63 -168
  7. package/child_process.d.ts +117 -223
  8. package/cluster.d.ts +251 -329
  9. package/compatibility/iterators.d.ts +15 -0
  10. package/console.d.ts +60 -346
  11. package/constants.d.ts +15 -1
  12. package/crypto.d.ts +713 -1149
  13. package/dgram.d.ts +30 -50
  14. package/diagnostics_channel.d.ts +16 -3
  15. package/dns/promises.d.ts +15 -0
  16. package/dns.d.ts +150 -131
  17. package/domain.d.ts +25 -14
  18. package/events.d.ts +858 -719
  19. package/fs/promises.d.ts +117 -53
  20. package/fs.d.ts +729 -484
  21. package/globals.d.ts +142 -344
  22. package/globals.typedarray.d.ts +94 -0
  23. package/http.d.ts +358 -246
  24. package/http2.d.ts +578 -711
  25. package/https.d.ts +85 -216
  26. package/index.d.ts +39 -3
  27. package/inspector/promises.d.ts +54 -0
  28. package/inspector.d.ts +180 -3936
  29. package/inspector.generated.d.ts +4242 -0
  30. package/module.d.ts +60 -95
  31. package/my-shim.d.ts +15 -0
  32. package/net.d.ts +102 -186
  33. package/os.d.ts +32 -6
  34. package/package.json +3 -8
  35. package/path/posix.d.ts +20 -0
  36. package/path/win32.d.ts +20 -0
  37. package/path.d.ts +132 -122
  38. package/perf_hooks.d.ts +310 -644
  39. package/process.d.ts +192 -138
  40. package/punycode.d.ts +17 -2
  41. package/querystring.d.ts +16 -1
  42. package/quic.d.ts +926 -0
  43. package/readline/promises.d.ts +16 -1
  44. package/readline.d.ts +80 -118
  45. package/repl.d.ts +98 -96
  46. package/sea.d.ts +25 -1
  47. package/sqlite.d.ts +277 -13
  48. package/stream/consumers.d.ts +22 -7
  49. package/stream/promises.d.ts +148 -12
  50. package/stream/web.d.ts +187 -494
  51. package/stream.d.ts +608 -490
  52. package/string_decoder.d.ts +18 -3
  53. package/test/reporters.d.ts +112 -0
  54. package/test.d.ts +238 -199
  55. package/timers/promises.d.ts +16 -1
  56. package/timers.d.ts +16 -129
  57. package/tls.d.ts +163 -163
  58. package/trace_events.d.ts +21 -6
  59. package/ts5.6/buffer.buffer.d.ts +25 -8
  60. package/ts5.6/compatibility/float16array.d.ts +15 -0
  61. package/ts5.6/globals.typedarray.d.ts +31 -0
  62. package/ts5.6/index.d.ts +39 -3
  63. package/ts5.7/compatibility/float16array.d.ts +15 -0
  64. package/ts5.7/index.d.ts +39 -3
  65. package/tty.d.ts +70 -13
  66. package/undici-types/agent.d.ts +20 -4
  67. package/undici-types/api.d.ts +15 -0
  68. package/undici-types/balanced-pool.d.ts +15 -0
  69. package/undici-types/cache-interceptor.d.ts +15 -0
  70. package/undici-types/cache.d.ts +15 -0
  71. package/undici-types/client-stats.d.ts +31 -0
  72. package/undici-types/client.d.ts +21 -5
  73. package/undici-types/connector.d.ts +15 -0
  74. package/undici-types/content-type.d.ts +15 -0
  75. package/undici-types/cookies.d.ts +15 -0
  76. package/undici-types/diagnostics-channel.d.ts +24 -1
  77. package/undici-types/dispatcher.d.ts +18 -8
  78. package/undici-types/env-http-proxy-agent.d.ts +17 -1
  79. package/undici-types/errors.d.ts +20 -15
  80. package/undici-types/eventsource.d.ts +24 -4
  81. package/undici-types/fetch.d.ts +16 -0
  82. package/undici-types/formdata.d.ts +15 -0
  83. package/undici-types/global-dispatcher.d.ts +15 -0
  84. package/undici-types/global-origin.d.ts +15 -0
  85. package/undici-types/h2c-client.d.ts +15 -2
  86. package/undici-types/handlers.d.ts +16 -1
  87. package/undici-types/header.d.ts +15 -0
  88. package/undici-types/index.d.ts +21 -1
  89. package/undici-types/interceptors.d.ts +20 -0
  90. package/undici-types/mock-agent.d.ts +18 -0
  91. package/undici-types/mock-call-history.d.ts +15 -0
  92. package/undici-types/mock-client.d.ts +17 -0
  93. package/undici-types/mock-errors.d.ts +15 -0
  94. package/undici-types/mock-interceptor.d.ts +17 -1
  95. package/undici-types/mock-pool.d.ts +17 -0
  96. package/undici-types/package.json +1 -1
  97. package/undici-types/patch.d.ts +15 -0
  98. package/undici-types/pool-stats.d.ts +15 -0
  99. package/undici-types/pool.d.ts +17 -0
  100. package/undici-types/proxy-agent.d.ts +16 -0
  101. package/undici-types/readable.d.ts +15 -0
  102. package/undici-types/retry-agent.d.ts +15 -0
  103. package/undici-types/retry-handler.d.ts +24 -0
  104. package/undici-types/snapshot-agent.d.ts +125 -0
  105. package/undici-types/util.d.ts +15 -0
  106. package/undici-types/utility.d.ts +15 -0
  107. package/undici-types/webidl.d.ts +126 -36
  108. package/undici-types/websocket.d.ts +18 -1
  109. package/url.d.ts +107 -587
  110. package/util/types.d.ts +571 -0
  111. package/util.d.ts +158 -792
  112. package/v8.d.ts +82 -7
  113. package/vm.d.ts +267 -108
  114. package/wasi.d.ts +38 -2
  115. package/web-globals/abortcontroller.d.ts +75 -0
  116. package/web-globals/blob.d.ts +39 -0
  117. package/web-globals/console.d.ts +25 -0
  118. package/web-globals/crypto.d.ts +55 -0
  119. package/web-globals/domexception.d.ts +84 -0
  120. package/web-globals/encoding.d.ts +27 -0
  121. package/{dom-events.d.ts → web-globals/events.d.ts} +72 -50
  122. package/web-globals/fetch.d.ts +70 -0
  123. package/web-globals/importmeta.d.ts +29 -0
  124. package/web-globals/messaging.d.ts +39 -0
  125. package/web-globals/navigator.d.ts +41 -0
  126. package/web-globals/performance.d.ts +61 -0
  127. package/web-globals/storage.d.ts +40 -0
  128. package/web-globals/streams.d.ts +131 -0
  129. package/web-globals/timers.d.ts +60 -0
  130. package/web-globals/url.d.ts +40 -0
  131. package/worker_threads.d.ts +306 -349
  132. package/zlib.d.ts +59 -94
  133. package/ts5.1/compatibility/disposable.d.ts +0 -13
  134. package/ts5.1/index.d.ts +0 -100
package/util.d.ts CHANGED
@@ -1,3 +1,18 @@
1
+ // biome-ignore-all lint: generated file
2
+ // biome-ignore-all assist: generated file
3
+ /* eslint-disable */
4
+ // @ts-ignore
5
+
6
+ /******************************************************************************
7
+ * GENERATED FILE, DO NOT MODIFY
8
+ * 这是生成的文件,千万不要修改
9
+ *
10
+ * @build-script/codegen - The Simple Code Generater
11
+ * https://github.com/GongT/baobao
12
+ *
13
+ ******************************************************************************/
14
+
15
+
1
16
  /**
2
17
  * The `node:util` module supports the needs of Node.js internal APIs. Many of the
3
18
  * utilities are useful for application and module developers as well. To access
@@ -6,11 +21,61 @@
6
21
  * ```js
7
22
  * import util from 'node:util';
8
23
  * ```
9
- * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/util.js)
24
+ * @see [source](https://github.com/nodejs/node/blob/v25.x/lib/util.js)
10
25
  */
11
26
 
12
27
  declare module "node:util" {
13
- import * as types from 'node:util/types';
28
+ export * as types from "node:util/types";
29
+ export type InspectStyle =
30
+ | "special"
31
+ | "number"
32
+ | "bigint"
33
+ | "boolean"
34
+ | "undefined"
35
+ | "null"
36
+ | "string"
37
+ | "symbol"
38
+ | "date"
39
+ | "name"
40
+ | "regexp"
41
+ | "module";
42
+ export interface InspectStyles extends Record<InspectStyle, InspectColor | ((value: string) => string)> {
43
+ regexp: {
44
+ (value: string): string;
45
+ colors: InspectColor[];
46
+ };
47
+ }
48
+ export type InspectColorModifier =
49
+ | "reset"
50
+ | "bold"
51
+ | "dim"
52
+ | "italic"
53
+ | "underline"
54
+ | "blink"
55
+ | "inverse"
56
+ | "hidden"
57
+ | "strikethrough"
58
+ | "doubleunderline";
59
+ export type InspectColorForeground =
60
+ | "black"
61
+ | "red"
62
+ | "green"
63
+ | "yellow"
64
+ | "blue"
65
+ | "magenta"
66
+ | "cyan"
67
+ | "white"
68
+ | "gray"
69
+ | "redBright"
70
+ | "greenBright"
71
+ | "yellowBright"
72
+ | "blueBright"
73
+ | "magentaBright"
74
+ | "cyanBright"
75
+ | "whiteBright";
76
+ export type InspectColorBackground = `bg${Capitalize<InspectColorForeground>}`;
77
+ export type InspectColor = InspectColorModifier | InspectColorForeground | InspectColorBackground;
78
+ export interface InspectColors extends Record<InspectColor, [number, number]> {}
14
79
  export interface InspectOptions {
15
80
  /**
16
81
  * If `true`, object's non-enumerable symbols and properties are included in the formatted result.
@@ -93,22 +158,26 @@ declare module "node:util" {
93
158
  */
94
159
  numericSeparator?: boolean | undefined;
95
160
  }
96
- export type Style =
97
- | "special"
98
- | "number"
99
- | "bigint"
100
- | "boolean"
101
- | "undefined"
102
- | "null"
103
- | "string"
104
- | "symbol"
105
- | "date"
106
- | "regexp"
107
- | "module";
108
- export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => any; // TODO: , inspect: inspect
109
- export interface InspectOptionsStylized extends InspectOptions {
110
- stylize(text: string, styleType: Style): string;
161
+ export interface InspectContext extends Required<InspectOptions> {
162
+ stylize(text: string, styleType: InspectStyle): string;
111
163
  }
164
+ import _inspect = inspect;
165
+ export interface Inspectable {
166
+ [inspect.custom](depth: number, options: InspectContext, inspect: typeof _inspect): any;
167
+ }
168
+ // TODO: Remove these in a future major
169
+ /** @deprecated Use `InspectStyle` instead. */
170
+ export type Style = Exclude<InspectStyle, "name">;
171
+ /** @deprecated Use the `Inspectable` interface instead. */
172
+ export type CustomInspectFunction = (depth: number, options: InspectContext) => any;
173
+ /** @deprecated Use `InspectContext` instead. */
174
+ export interface InspectOptionsStylized extends InspectContext {}
175
+ /** @deprecated Use `InspectColorModifier` instead. */
176
+ export type Modifiers = InspectColorModifier;
177
+ /** @deprecated Use `InspectColorForeground` instead. */
178
+ export type ForegroundColors = InspectColorForeground;
179
+ /** @deprecated Use `InspectColorBackground` instead. */
180
+ export type BackgroundColors = InspectColorBackground;
112
181
  export interface CallSiteObject {
113
182
  /**
114
183
  * Returns the name of the function associated with this call site.
@@ -244,7 +313,7 @@ declare module "node:util" {
244
313
  * @since v10.0.0
245
314
  */
246
315
  export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string;
247
- interface GetCallSitesOptions {
316
+ export interface GetCallSitesOptions {
248
317
  /**
249
318
  * Reconstruct the original location in the stacktrace from the source-map.
250
319
  * Enabled by default with the flag `--enable-source-maps`.
@@ -339,6 +408,11 @@ declare module "node:util" {
339
408
  * @since v9.7.0
340
409
  */
341
410
  export function getSystemErrorName(err: number): string;
411
+ /**
412
+ * Enable or disable printing a stack trace on `SIGINT`. The API is only available on the main thread.
413
+ * @since 24.6.0
414
+ */
415
+ export function setTraceSigInt(enable: boolean): void;
342
416
  /**
343
417
  * Returns a Map of all system error codes available from the Node.js API.
344
418
  * The mapping between error codes and error names is platform-dependent.
@@ -432,8 +506,8 @@ declare module "node:util" {
432
506
  * intended for debugging. The output of `util.inspect` may change at any time
433
507
  * and should not be depended upon programmatically. Additional `options` may be
434
508
  * passed that alter the result.
435
- * `util.inspect()` will use the constructor's name and/or `@@toStringTag` to make
436
- * an identifiable tag for an inspected value.
509
+ * `util.inspect()` will use the constructor's name and/or `Symbol.toStringTag`
510
+ * property to make an identifiable tag for an inspected value.
437
511
  *
438
512
  * ```js
439
513
  * class Foo {
@@ -605,19 +679,11 @@ declare module "node:util" {
605
679
  export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
606
680
  export function inspect(object: any, options?: InspectOptions): string;
607
681
  export namespace inspect {
608
- let colors: NodeJS.Dict<[number, number]>;
609
- let styles: {
610
- [K in Style]: string;
611
- };
682
+ const custom: unique symbol;
683
+ let colors: InspectColors;
684
+ let styles: InspectStyles;
612
685
  let defaultOptions: InspectOptions;
613
- /**
614
- * Allows changing inspect settings from the repl.
615
- */
616
686
  let replDefaults: InspectOptions;
617
- /**
618
- * That can be used to declare custom inspect functions.
619
- */
620
- const custom: unique symbol;
621
687
  }
622
688
  /**
623
689
  * Alias for [`Array.isArray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray).
@@ -849,6 +915,15 @@ declare module "node:util" {
849
915
  * @return The deprecated function wrapped to emit a warning.
850
916
  */
851
917
  export function deprecate<T extends Function>(fn: T, msg: string, code?: string): T;
918
+ export interface IsDeepStrictEqualOptions {
919
+ /**
920
+ * If `true`, prototype and constructor
921
+ * comparison is skipped during deep strict equality check.
922
+ * @since v24.9.0
923
+ * @default false
924
+ */
925
+ skipPrototype?: boolean | undefined;
926
+ }
852
927
  /**
853
928
  * Returns `true` if there is deep strict equality between `val1` and `val2`.
854
929
  * Otherwise, returns `false`.
@@ -857,7 +932,7 @@ declare module "node:util" {
857
932
  * equality.
858
933
  * @since v9.0.0
859
934
  */
860
- export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean;
935
+ export function isDeepStrictEqual(val1: unknown, val2: unknown, options?: IsDeepStrictEqualOptions): boolean;
861
936
  /**
862
937
  * Returns `str` with any ANSI escape codes removed.
863
938
  *
@@ -1032,7 +1107,7 @@ declare module "node:util" {
1032
1107
  * ```
1033
1108
  *
1034
1109
  * If there is an `original[util.promisify.custom]` property present, `promisify`
1035
- * will return its value, see [Custom promisified functions](https://nodejs.org/docs/latest-v24.x/api/util.html#custom-promisified-functions).
1110
+ * will return its value, see [Custom promisified functions](https://nodejs.org/docs/latest-v25.x/api/util.html#custom-promisified-functions).
1036
1111
  *
1037
1112
  * `promisify()` assumes that `original` is a function taking a callback as its
1038
1113
  * final argument in all cases. If `original` is not a function, `promisify()`
@@ -1123,60 +1198,6 @@ declare module "node:util" {
1123
1198
  * @since v20.12.0
1124
1199
  */
1125
1200
  export function parseEnv(content: string): NodeJS.Dict<string>;
1126
- // https://nodejs.org/docs/latest/api/util.html#foreground-colors
1127
- type ForegroundColors =
1128
- | "black"
1129
- | "blackBright"
1130
- | "blue"
1131
- | "blueBright"
1132
- | "cyan"
1133
- | "cyanBright"
1134
- | "gray"
1135
- | "green"
1136
- | "greenBright"
1137
- | "grey"
1138
- | "magenta"
1139
- | "magentaBright"
1140
- | "red"
1141
- | "redBright"
1142
- | "white"
1143
- | "whiteBright"
1144
- | "yellow"
1145
- | "yellowBright";
1146
- // https://nodejs.org/docs/latest/api/util.html#background-colors
1147
- type BackgroundColors =
1148
- | "bgBlack"
1149
- | "bgBlackBright"
1150
- | "bgBlue"
1151
- | "bgBlueBright"
1152
- | "bgCyan"
1153
- | "bgCyanBright"
1154
- | "bgGray"
1155
- | "bgGreen"
1156
- | "bgGreenBright"
1157
- | "bgGrey"
1158
- | "bgMagenta"
1159
- | "bgMagentaBright"
1160
- | "bgRed"
1161
- | "bgRedBright"
1162
- | "bgWhite"
1163
- | "bgWhiteBright"
1164
- | "bgYellow"
1165
- | "bgYellowBright";
1166
- // https://nodejs.org/docs/latest/api/util.html#modifiers
1167
- type Modifiers =
1168
- | "blink"
1169
- | "bold"
1170
- | "dim"
1171
- | "doubleunderline"
1172
- | "framed"
1173
- | "hidden"
1174
- | "inverse"
1175
- | "italic"
1176
- | "overlined"
1177
- | "reset"
1178
- | "strikethrough"
1179
- | "underline";
1180
1201
  export interface StyleTextOptions {
1181
1202
  /**
1182
1203
  * When true, `stream` is checked to see if it can handle colors.
@@ -1229,142 +1250,21 @@ declare module "node:util" {
1229
1250
  * );
1230
1251
  * ```
1231
1252
  *
1232
- * The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v24.x/api/util.html#modifiers).
1253
+ * The special format value `none` applies no additional styling to the text.
1254
+ *
1255
+ * The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v25.x/api/util.html#modifiers).
1233
1256
  * @param format A text format or an Array of text formats defined in `util.inspect.colors`.
1234
1257
  * @param text The text to to be formatted.
1235
1258
  * @since v20.12.0
1236
1259
  */
1237
1260
  export function styleText(
1238
- format:
1239
- | ForegroundColors
1240
- | BackgroundColors
1241
- | Modifiers
1242
- | Array<ForegroundColors | BackgroundColors | Modifiers>,
1261
+ format: InspectColor | readonly InspectColor[],
1243
1262
  text: string,
1244
1263
  options?: StyleTextOptions,
1245
1264
  ): string;
1246
- /**
1247
- * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextDecoder` API.
1248
- *
1249
- * ```js
1250
- * const decoder = new TextDecoder();
1251
- * const u8arr = new Uint8Array([72, 101, 108, 108, 111]);
1252
- * console.log(decoder.decode(u8arr)); // Hello
1253
- * ```
1254
- * @since v8.3.0
1255
- */
1256
- export class TextDecoder {
1257
- /**
1258
- * The encoding supported by the `TextDecoder` instance.
1259
- */
1260
- readonly encoding: string;
1261
- /**
1262
- * The value will be `true` if decoding errors result in a `TypeError` being
1263
- * thrown.
1264
- */
1265
- readonly fatal: boolean;
1266
- /**
1267
- * The value will be `true` if the decoding result will include the byte order
1268
- * mark.
1269
- */
1270
- readonly ignoreBOM: boolean;
1271
- constructor(
1272
- encoding?: string,
1273
- options?: {
1274
- fatal?: boolean | undefined;
1275
- ignoreBOM?: boolean | undefined;
1276
- },
1277
- );
1278
- /**
1279
- * Decodes the `input` and returns a string. If `options.stream` is `true`, any
1280
- * incomplete byte sequences occurring at the end of the `input` are buffered
1281
- * internally and emitted after the next call to `textDecoder.decode()`.
1282
- *
1283
- * If `textDecoder.fatal` is `true`, decoding errors that occur will result in a `TypeError` being thrown.
1284
- * @param input An `ArrayBuffer`, `DataView`, or `TypedArray` instance containing the encoded data.
1285
- */
1286
- decode(
1287
- input?: NodeJS.ArrayBufferView | ArrayBuffer | null,
1288
- options?: {
1289
- stream?: boolean | undefined;
1290
- },
1291
- ): string;
1292
- }
1293
- export interface EncodeIntoResult {
1294
- /**
1295
- * The read Unicode code units of input.
1296
- */
1297
- read: number;
1298
- /**
1299
- * The written UTF-8 bytes of output.
1300
- */
1301
- written: number;
1302
- }
1303
- export { types };
1304
-
1305
- //// TextEncoder/Decoder
1306
- /**
1307
- * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextEncoder` API. All
1308
- * instances of `TextEncoder` only support UTF-8 encoding.
1309
- *
1310
- * ```js
1311
- * const encoder = new TextEncoder();
1312
- * const uint8array = encoder.encode('this is some data');
1313
- * ```
1314
- *
1315
- * The `TextEncoder` class is also available on the global object.
1316
- * @since v8.3.0
1317
- */
1318
- export class TextEncoder {
1319
- /**
1320
- * The encoding supported by the `TextEncoder` instance. Always set to `'utf-8'`.
1321
- */
1322
- readonly encoding: string;
1323
- /**
1324
- * UTF-8 encodes the `input` string and returns a `Uint8Array` containing the
1325
- * encoded bytes.
1326
- * @param [input='an empty string'] The text to encode.
1327
- */
1328
- encode(input?: string): Uint8Array;
1329
- /**
1330
- * UTF-8 encodes the `src` string to the `dest` Uint8Array and returns an object
1331
- * containing the read Unicode code units and written UTF-8 bytes.
1332
- *
1333
- * ```js
1334
- * const encoder = new TextEncoder();
1335
- * const src = 'this is some data';
1336
- * const dest = new Uint8Array(10);
1337
- * const { read, written } = encoder.encodeInto(src, dest);
1338
- * ```
1339
- * @param src The text to encode.
1340
- * @param dest The array to hold the encode result.
1341
- */
1342
- encodeInto(src: string, dest: Uint8Array): EncodeIntoResult;
1343
- }
1344
- import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from 'node:util';
1345
- global {
1346
- /**
1347
- * `TextDecoder` class is a global reference for `import { TextDecoder } from 'node:util'`
1348
- * https://nodejs.org/api/globals.html#textdecoder
1349
- * @since v11.0.0
1350
- */
1351
- var TextDecoder: typeof globalThis extends {
1352
- onmessage: any;
1353
- TextDecoder: infer TextDecoder;
1354
- } ? TextDecoder
1355
- : typeof _TextDecoder;
1356
- /**
1357
- * `TextEncoder` class is a global reference for `import { TextEncoder } from 'node:util'`
1358
- * https://nodejs.org/api/globals.html#textencoder
1359
- * @since v11.0.0
1360
- */
1361
- var TextEncoder: typeof globalThis extends {
1362
- onmessage: any;
1363
- TextEncoder: infer TextEncoder;
1364
- } ? TextEncoder
1365
- : typeof _TextEncoder;
1366
- }
1367
-
1265
+ /** @deprecated This alias will be removed in a future version. Use the canonical `TextEncoderEncodeIntoResult` instead. */
1266
+ // TODO: remove in future major
1267
+ export interface EncodeIntoResult extends TextEncoderEncodeIntoResult {}
1368
1268
  //// parseArgs
1369
1269
  /**
1370
1270
  * Provides a higher level API for command-line argument parsing than interacting
@@ -1395,12 +1295,10 @@ declare module "node:util" {
1395
1295
  * @return The parsed command line arguments:
1396
1296
  */
1397
1297
  export function parseArgs<T extends ParseArgsConfig>(config?: T): ParsedResults<T>;
1398
-
1399
1298
  /**
1400
1299
  * Type of argument used in {@link parseArgs}.
1401
1300
  */
1402
1301
  export type ParseArgsOptionsType = "boolean" | "string";
1403
-
1404
1302
  export interface ParseArgsOptionDescriptor {
1405
1303
  /**
1406
1304
  * Type of argument.
@@ -1418,10 +1316,12 @@ declare module "node:util" {
1418
1316
  */
1419
1317
  short?: string | undefined;
1420
1318
  /**
1421
- * The default value to
1422
- * be used if (and only if) the option does not appear in the arguments to be
1423
- * parsed. It must be of the same type as the `type` property. When `multiple`
1424
- * is `true`, it must be an array.
1319
+ * The value to assign to
1320
+ * the option if it does not appear in the arguments to be parsed. The value
1321
+ * must match the type specified by the `type` property. If `multiple` is
1322
+ * `true`, it must be an array. No default value is applied when the option
1323
+ * does appear in the arguments to be parsed, even if the provided value
1324
+ * is falsy.
1425
1325
  * @since v18.11.0
1426
1326
  */
1427
1327
  default?: string | boolean | string[] | boolean[] | undefined;
@@ -1433,7 +1333,7 @@ declare module "node:util" {
1433
1333
  /**
1434
1334
  * Array of argument strings.
1435
1335
  */
1436
- args?: string[] | undefined;
1336
+ args?: readonly string[] | undefined;
1437
1337
  /**
1438
1338
  * Used to describe arguments known to the parser.
1439
1339
  */
@@ -1473,23 +1373,19 @@ declare module "node:util" {
1473
1373
  type IfDefaultsTrue<T, IfTrue, IfFalse> = T extends true ? IfTrue
1474
1374
  : T extends false ? IfFalse
1475
1375
  : IfTrue;
1476
-
1477
1376
  // we put the `extends false` condition first here because `undefined` compares like `any` when `strictNullChecks: false`
1478
1377
  type IfDefaultsFalse<T, IfTrue, IfFalse> = T extends false ? IfFalse
1479
1378
  : T extends true ? IfTrue
1480
1379
  : IfFalse;
1481
-
1482
1380
  type ExtractOptionValue<T extends ParseArgsConfig, O extends ParseArgsOptionDescriptor> = IfDefaultsTrue<
1483
1381
  T["strict"],
1484
1382
  O["type"] extends "string" ? string : O["type"] extends "boolean" ? boolean : string | boolean,
1485
1383
  string | boolean
1486
1384
  >;
1487
-
1488
1385
  type ApplyOptionalModifiers<O extends ParseArgsOptionsConfig, V extends Record<keyof O, unknown>> = (
1489
1386
  & { -readonly [LongOption in keyof O]?: V[LongOption] }
1490
1387
  & { [LongOption in keyof O as O[LongOption]["default"] extends {} ? LongOption : never]: V[LongOption] }
1491
1388
  ) extends infer P ? { [K in keyof P]: P[K] } : never; // resolve intersection to object
1492
-
1493
1389
  type ParsedValues<T extends ParseArgsConfig> =
1494
1390
  & IfDefaultsTrue<T["strict"], unknown, { [longOption: string]: undefined | string | boolean }>
1495
1391
  & (T["options"] extends ParseArgsOptionsConfig ? ApplyOptionalModifiers<
@@ -1503,13 +1399,11 @@ declare module "node:util" {
1503
1399
  }
1504
1400
  >
1505
1401
  : {});
1506
-
1507
1402
  type ParsedPositionals<T extends ParseArgsConfig> = IfDefaultsTrue<
1508
1403
  T["strict"],
1509
1404
  IfDefaultsFalse<T["allowPositionals"], string[], []>,
1510
1405
  IfDefaultsTrue<T["allowPositionals"], string[], []>
1511
1406
  >;
1512
-
1513
1407
  type PreciseTokenForOptions<
1514
1408
  K extends string,
1515
1409
  O extends ParseArgsOptionDescriptor,
@@ -1530,7 +1424,6 @@ declare module "node:util" {
1530
1424
  inlineValue: undefined;
1531
1425
  }
1532
1426
  : OptionToken & { name: K };
1533
-
1534
1427
  type TokenForOptions<
1535
1428
  T extends ParseArgsConfig,
1536
1429
  K extends keyof T["options"] = keyof T["options"],
@@ -1538,19 +1431,15 @@ declare module "node:util" {
1538
1431
  ? T["options"] extends ParseArgsOptionsConfig ? PreciseTokenForOptions<K & string, T["options"][K]>
1539
1432
  : OptionToken
1540
1433
  : never;
1541
-
1542
1434
  type ParsedOptionToken<T extends ParseArgsConfig> = IfDefaultsTrue<T["strict"], TokenForOptions<T>, OptionToken>;
1543
-
1544
1435
  type ParsedPositionalToken<T extends ParseArgsConfig> = IfDefaultsTrue<
1545
1436
  T["strict"],
1546
1437
  IfDefaultsFalse<T["allowPositionals"], { kind: "positional"; index: number; value: string }, never>,
1547
1438
  IfDefaultsTrue<T["allowPositionals"], { kind: "positional"; index: number; value: string }, never>
1548
1439
  >;
1549
-
1550
1440
  type ParsedTokens<T extends ParseArgsConfig> = Array<
1551
1441
  ParsedOptionToken<T> | ParsedPositionalToken<T> | { kind: "option-terminator"; index: number }
1552
1442
  >;
1553
-
1554
1443
  type PreciseParsedResults<T extends ParseArgsConfig> = IfDefaultsFalse<
1555
1444
  T["tokens"],
1556
1445
  {
@@ -1563,7 +1452,6 @@ declare module "node:util" {
1563
1452
  positionals: ParsedPositionals<T>;
1564
1453
  }
1565
1454
  >;
1566
-
1567
1455
  type OptionToken =
1568
1456
  | { kind: "option"; index: number; name: string; rawName: string; value: string; inlineValue: boolean }
1569
1457
  | {
@@ -1574,12 +1462,10 @@ declare module "node:util" {
1574
1462
  value: undefined;
1575
1463
  inlineValue: undefined;
1576
1464
  };
1577
-
1578
1465
  type Token =
1579
1466
  | OptionToken
1580
1467
  | { kind: "positional"; index: number; value: string }
1581
1468
  | { kind: "option-terminator"; index: number };
1582
-
1583
1469
  // If ParseArgsConfig extends T, then the user passed config constructed elsewhere.
1584
1470
  // So we can't rely on the `"not definitely present" implies "definitely not present"` assumption mentioned above.
1585
1471
  type ParsedResults<T extends ParseArgsConfig> = ParseArgsConfig extends T ? {
@@ -1590,7 +1476,6 @@ declare module "node:util" {
1590
1476
  tokens?: Token[];
1591
1477
  }
1592
1478
  : PreciseParsedResults<T>;
1593
-
1594
1479
  /**
1595
1480
  * An implementation of [the MIMEType class](https://bmeck.github.io/node-proposal-mime-api/).
1596
1481
  *
@@ -1612,7 +1497,6 @@ declare module "node:util" {
1612
1497
  * @param input The input MIME to parse.
1613
1498
  */
1614
1499
  constructor(input: string | { toString: () => string });
1615
-
1616
1500
  /**
1617
1501
  * Gets and sets the type portion of the MIME.
1618
1502
  *
@@ -1743,558 +1627,40 @@ declare module "node:util" {
1743
1627
  */
1744
1628
  [Symbol.iterator](): NodeJS.Iterator<[name: string, value: string]>;
1745
1629
  }
1746
- }
1747
- declare module "node:util/types" {
1748
- import { KeyObject, webcrypto } from 'node:crypto';
1749
- /**
1750
- * Returns `true` if the value is a built-in [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) or
1751
- * [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instance.
1752
- *
1753
- * See also `util.types.isArrayBuffer()` and `util.types.isSharedArrayBuffer()`.
1754
- *
1755
- * ```js
1756
- * util.types.isAnyArrayBuffer(new ArrayBuffer()); // Returns true
1757
- * util.types.isAnyArrayBuffer(new SharedArrayBuffer()); // Returns true
1758
- * ```
1759
- * @since v10.0.0
1760
- */
1761
- function isAnyArrayBuffer(object: unknown): object is ArrayBufferLike;
1762
- /**
1763
- * Returns `true` if the value is an `arguments` object.
1764
- *
1765
- * ```js
1766
- * function foo() {
1767
- * util.types.isArgumentsObject(arguments); // Returns true
1768
- * }
1769
- * ```
1770
- * @since v10.0.0
1771
- */
1772
- function isArgumentsObject(object: unknown): object is IArguments;
1773
- /**
1774
- * Returns `true` if the value is a built-in [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) instance.
1775
- * This does _not_ include [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instances. Usually, it is
1776
- * desirable to test for both; See `util.types.isAnyArrayBuffer()` for that.
1777
- *
1778
- * ```js
1779
- * util.types.isArrayBuffer(new ArrayBuffer()); // Returns true
1780
- * util.types.isArrayBuffer(new SharedArrayBuffer()); // Returns false
1781
- * ```
1782
- * @since v10.0.0
1783
- */
1784
- function isArrayBuffer(object: unknown): object is ArrayBuffer;
1785
- /**
1786
- * Returns `true` if the value is an instance of one of the [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) views, such as typed
1787
- * array objects or [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView). Equivalent to
1788
- * [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
1789
- *
1790
- * ```js
1791
- * util.types.isArrayBufferView(new Int8Array()); // true
1792
- * util.types.isArrayBufferView(Buffer.from('hello world')); // true
1793
- * util.types.isArrayBufferView(new DataView(new ArrayBuffer(16))); // true
1794
- * util.types.isArrayBufferView(new ArrayBuffer()); // false
1795
- * ```
1796
- * @since v10.0.0
1797
- */
1798
- function isArrayBufferView(object: unknown): object is NodeJS.ArrayBufferView;
1799
- /**
1800
- * Returns `true` if the value is an [async function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function).
1801
- * This only reports back what the JavaScript engine is seeing;
1802
- * in particular, the return value may not match the original source code if
1803
- * a transpilation tool was used.
1804
- *
1805
- * ```js
1806
- * util.types.isAsyncFunction(function foo() {}); // Returns false
1807
- * util.types.isAsyncFunction(async function foo() {}); // Returns true
1808
- * ```
1809
- * @since v10.0.0
1810
- */
1811
- function isAsyncFunction(object: unknown): boolean;
1812
- /**
1813
- * Returns `true` if the value is a `BigInt64Array` instance.
1814
- *
1815
- * ```js
1816
- * util.types.isBigInt64Array(new BigInt64Array()); // Returns true
1817
- * util.types.isBigInt64Array(new BigUint64Array()); // Returns false
1818
- * ```
1819
- * @since v10.0.0
1820
- */
1821
- function isBigInt64Array(value: unknown): value is BigInt64Array;
1822
- /**
1823
- * Returns `true` if the value is a BigInt object, e.g. created
1824
- * by `Object(BigInt(123))`.
1825
- *
1826
- * ```js
1827
- * util.types.isBigIntObject(Object(BigInt(123))); // Returns true
1828
- * util.types.isBigIntObject(BigInt(123)); // Returns false
1829
- * util.types.isBigIntObject(123); // Returns false
1830
- * ```
1831
- * @since v10.4.0
1832
- */
1833
- function isBigIntObject(object: unknown): object is BigInt;
1834
- /**
1835
- * Returns `true` if the value is a `BigUint64Array` instance.
1836
- *
1837
- * ```js
1838
- * util.types.isBigUint64Array(new BigInt64Array()); // Returns false
1839
- * util.types.isBigUint64Array(new BigUint64Array()); // Returns true
1840
- * ```
1841
- * @since v10.0.0
1842
- */
1843
- function isBigUint64Array(value: unknown): value is BigUint64Array;
1844
- /**
1845
- * Returns `true` if the value is a boolean object, e.g. created
1846
- * by `new Boolean()`.
1847
- *
1848
- * ```js
1849
- * util.types.isBooleanObject(false); // Returns false
1850
- * util.types.isBooleanObject(true); // Returns false
1851
- * util.types.isBooleanObject(new Boolean(false)); // Returns true
1852
- * util.types.isBooleanObject(new Boolean(true)); // Returns true
1853
- * util.types.isBooleanObject(Boolean(false)); // Returns false
1854
- * util.types.isBooleanObject(Boolean(true)); // Returns false
1855
- * ```
1856
- * @since v10.0.0
1857
- */
1858
- function isBooleanObject(object: unknown): object is Boolean;
1859
- /**
1860
- * Returns `true` if the value is any boxed primitive object, e.g. created
1861
- * by `new Boolean()`, `new String()` or `Object(Symbol())`.
1862
- *
1863
- * For example:
1864
- *
1865
- * ```js
1866
- * util.types.isBoxedPrimitive(false); // Returns false
1867
- * util.types.isBoxedPrimitive(new Boolean(false)); // Returns true
1868
- * util.types.isBoxedPrimitive(Symbol('foo')); // Returns false
1869
- * util.types.isBoxedPrimitive(Object(Symbol('foo'))); // Returns true
1870
- * util.types.isBoxedPrimitive(Object(BigInt(5))); // Returns true
1871
- * ```
1872
- * @since v10.11.0
1873
- */
1874
- function isBoxedPrimitive(object: unknown): object is String | Number | BigInt | Boolean | Symbol;
1875
- /**
1876
- * Returns `true` if the value is a built-in [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) instance.
1877
- *
1878
- * ```js
1879
- * const ab = new ArrayBuffer(20);
1880
- * util.types.isDataView(new DataView(ab)); // Returns true
1881
- * util.types.isDataView(new Float64Array()); // Returns false
1882
- * ```
1883
- *
1884
- * See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
1885
- * @since v10.0.0
1886
- */
1887
- function isDataView(object: unknown): object is DataView;
1888
- /**
1889
- * Returns `true` if the value is a built-in [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) instance.
1890
- *
1891
- * ```js
1892
- * util.types.isDate(new Date()); // Returns true
1893
- * ```
1894
- * @since v10.0.0
1895
- */
1896
- function isDate(object: unknown): object is Date;
1897
- /**
1898
- * Returns `true` if the value is a native `External` value.
1899
- *
1900
- * A native `External` value is a special type of object that contains a
1901
- * raw C++ pointer (`void*`) for access from native code, and has no other
1902
- * properties. Such objects are created either by Node.js internals or native
1903
- * addons. In JavaScript, they are
1904
- * [frozen](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) objects with a
1905
- * `null` prototype.
1906
- *
1907
- * ```c
1908
- * #include <js_native_api.h>
1909
- * #include <stdlib.h>
1910
- * napi_value result;
1911
- * static napi_value MyNapi(napi_env env, napi_callback_info info) {
1912
- * int* raw = (int*) malloc(1024);
1913
- * napi_status status = napi_create_external(env, (void*) raw, NULL, NULL, &result);
1914
- * if (status != napi_ok) {
1915
- * napi_throw_error(env, NULL, "napi_create_external failed");
1916
- * return NULL;
1917
- * }
1918
- * return result;
1919
- * }
1920
- * ...
1921
- * DECLARE_NAPI_PROPERTY("myNapi", MyNapi)
1922
- * ...
1923
- * ```
1924
- *
1925
- * ```js
1926
- * import native from 'napi_addon.node';
1927
- * import { types } from 'node:util';
1928
- *
1929
- * const data = native.myNapi();
1930
- * types.isExternal(data); // returns true
1931
- * types.isExternal(0); // returns false
1932
- * types.isExternal(new String('foo')); // returns false
1933
- * ```
1934
- *
1935
- * For further information on `napi_create_external`, refer to
1936
- * [`napi_create_external()`](https://nodejs.org/docs/latest-v24.x/api/n-api.html#napi_create_external).
1937
- * @since v10.0.0
1938
- */
1939
- function isExternal(object: unknown): boolean;
1940
- /**
1941
- * Returns `true` if the value is a built-in [`Float16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array) instance.
1942
- *
1943
- * ```js
1944
- * util.types.isFloat16Array(new ArrayBuffer()); // Returns false
1945
- * util.types.isFloat16Array(new Float16Array()); // Returns true
1946
- * util.types.isFloat16Array(new Float32Array()); // Returns false
1947
- * ```
1948
- * @since v24.0.0
1949
- */
1950
- function isFloat16Array(object: unknown): object is Float16Array;
1951
- /**
1952
- * Returns `true` if the value is a built-in [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array) instance.
1953
- *
1954
- * ```js
1955
- * util.types.isFloat32Array(new ArrayBuffer()); // Returns false
1956
- * util.types.isFloat32Array(new Float32Array()); // Returns true
1957
- * util.types.isFloat32Array(new Float64Array()); // Returns false
1958
- * ```
1959
- * @since v10.0.0
1960
- */
1961
- function isFloat32Array(object: unknown): object is Float32Array;
1962
- /**
1963
- * Returns `true` if the value is a built-in [`Float64Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array) instance.
1964
- *
1965
- * ```js
1966
- * util.types.isFloat64Array(new ArrayBuffer()); // Returns false
1967
- * util.types.isFloat64Array(new Uint8Array()); // Returns false
1968
- * util.types.isFloat64Array(new Float64Array()); // Returns true
1969
- * ```
1970
- * @since v10.0.0
1971
- */
1972
- function isFloat64Array(object: unknown): object is Float64Array;
1973
- /**
1974
- * Returns `true` if the value is a generator function.
1975
- * This only reports back what the JavaScript engine is seeing;
1976
- * in particular, the return value may not match the original source code if
1977
- * a transpilation tool was used.
1978
- *
1979
- * ```js
1980
- * util.types.isGeneratorFunction(function foo() {}); // Returns false
1981
- * util.types.isGeneratorFunction(function* foo() {}); // Returns true
1982
- * ```
1983
- * @since v10.0.0
1984
- */
1985
- function isGeneratorFunction(object: unknown): object is GeneratorFunction;
1986
- /**
1987
- * Returns `true` if the value is a generator object as returned from a
1988
- * built-in generator function.
1989
- * This only reports back what the JavaScript engine is seeing;
1990
- * in particular, the return value may not match the original source code if
1991
- * a transpilation tool was used.
1992
- *
1993
- * ```js
1994
- * function* foo() {}
1995
- * const generator = foo();
1996
- * util.types.isGeneratorObject(generator); // Returns true
1997
- * ```
1998
- * @since v10.0.0
1999
- */
2000
- function isGeneratorObject(object: unknown): object is Generator;
2001
- /**
2002
- * Returns `true` if the value is a built-in [`Int8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array) instance.
2003
- *
2004
- * ```js
2005
- * util.types.isInt8Array(new ArrayBuffer()); // Returns false
2006
- * util.types.isInt8Array(new Int8Array()); // Returns true
2007
- * util.types.isInt8Array(new Float64Array()); // Returns false
2008
- * ```
2009
- * @since v10.0.0
2010
- */
2011
- function isInt8Array(object: unknown): object is Int8Array;
2012
- /**
2013
- * Returns `true` if the value is a built-in [`Int16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array) instance.
2014
- *
2015
- * ```js
2016
- * util.types.isInt16Array(new ArrayBuffer()); // Returns false
2017
- * util.types.isInt16Array(new Int16Array()); // Returns true
2018
- * util.types.isInt16Array(new Float64Array()); // Returns false
2019
- * ```
2020
- * @since v10.0.0
2021
- */
2022
- function isInt16Array(object: unknown): object is Int16Array;
2023
- /**
2024
- * Returns `true` if the value is a built-in [`Int32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array) instance.
2025
- *
2026
- * ```js
2027
- * util.types.isInt32Array(new ArrayBuffer()); // Returns false
2028
- * util.types.isInt32Array(new Int32Array()); // Returns true
2029
- * util.types.isInt32Array(new Float64Array()); // Returns false
2030
- * ```
2031
- * @since v10.0.0
2032
- */
2033
- function isInt32Array(object: unknown): object is Int32Array;
2034
- /**
2035
- * Returns `true` if the value is a built-in [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance.
2036
- *
2037
- * ```js
2038
- * util.types.isMap(new Map()); // Returns true
2039
- * ```
2040
- * @since v10.0.0
2041
- */
2042
- function isMap<T>(
2043
- object: T | {},
2044
- ): object is T extends ReadonlyMap<any, any> ? (unknown extends T ? never : ReadonlyMap<any, any>)
2045
- : Map<unknown, unknown>;
2046
- /**
2047
- * Returns `true` if the value is an iterator returned for a built-in [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance.
2048
- *
2049
- * ```js
2050
- * const map = new Map();
2051
- * util.types.isMapIterator(map.keys()); // Returns true
2052
- * util.types.isMapIterator(map.values()); // Returns true
2053
- * util.types.isMapIterator(map.entries()); // Returns true
2054
- * util.types.isMapIterator(map[Symbol.iterator]()); // Returns true
2055
- * ```
2056
- * @since v10.0.0
2057
- */
2058
- function isMapIterator(object: unknown): boolean;
2059
- /**
2060
- * Returns `true` if the value is an instance of a [Module Namespace Object](https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects).
2061
- *
2062
- * ```js
2063
- * import * as ns from './a.js';
2064
- *
2065
- * util.types.isModuleNamespaceObject(ns); // Returns true
2066
- * ```
2067
- * @since v10.0.0
2068
- */
2069
- function isModuleNamespaceObject(value: unknown): boolean;
2070
- /**
2071
- * Returns `true` if the value was returned by the constructor of a
2072
- * [built-in `Error` type](https://tc39.es/ecma262/#sec-error-objects).
2073
- *
2074
- * ```js
2075
- * console.log(util.types.isNativeError(new Error())); // true
2076
- * console.log(util.types.isNativeError(new TypeError())); // true
2077
- * console.log(util.types.isNativeError(new RangeError())); // true
2078
- * ```
2079
- *
2080
- * Subclasses of the native error types are also native errors:
2081
- *
2082
- * ```js
2083
- * class MyError extends Error {}
2084
- * console.log(util.types.isNativeError(new MyError())); // true
2085
- * ```
2086
- *
2087
- * A value being `instanceof` a native error class is not equivalent to `isNativeError()`
2088
- * returning `true` for that value. `isNativeError()` returns `true` for errors
2089
- * which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false`
2090
- * for these errors:
2091
- *
2092
- * ```js
2093
- * import { createContext, runInContext } from 'node:vm';
2094
- * import { types } from 'node:util';
2095
- *
2096
- * const context = createContext({});
2097
- * const myError = runInContext('new Error()', context);
2098
- * console.log(types.isNativeError(myError)); // true
2099
- * console.log(myError instanceof Error); // false
2100
- * ```
2101
- *
2102
- * Conversely, `isNativeError()` returns `false` for all objects which were not
2103
- * returned by the constructor of a native error. That includes values
2104
- * which are `instanceof` native errors:
2105
- *
2106
- * ```js
2107
- * const myError = { __proto__: Error.prototype };
2108
- * console.log(util.types.isNativeError(myError)); // false
2109
- * console.log(myError instanceof Error); // true
2110
- * ```
2111
- * @since v10.0.0
2112
- */
2113
- function isNativeError(object: unknown): object is Error;
2114
- /**
2115
- * Returns `true` if the value is a number object, e.g. created
2116
- * by `new Number()`.
2117
- *
2118
- * ```js
2119
- * util.types.isNumberObject(0); // Returns false
2120
- * util.types.isNumberObject(new Number(0)); // Returns true
2121
- * ```
2122
- * @since v10.0.0
2123
- */
2124
- function isNumberObject(object: unknown): object is Number;
2125
- /**
2126
- * Returns `true` if the value is a built-in [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
2127
- *
2128
- * ```js
2129
- * util.types.isPromise(Promise.resolve(42)); // Returns true
2130
- * ```
2131
- * @since v10.0.0
2132
- */
2133
- function isPromise(object: unknown): object is Promise<unknown>;
2134
- /**
2135
- * Returns `true` if the value is a [`Proxy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) instance.
2136
- *
2137
- * ```js
2138
- * const target = {};
2139
- * const proxy = new Proxy(target, {});
2140
- * util.types.isProxy(target); // Returns false
2141
- * util.types.isProxy(proxy); // Returns true
2142
- * ```
2143
- * @since v10.0.0
2144
- */
2145
- function isProxy(object: unknown): boolean;
2146
- /**
2147
- * Returns `true` if the value is a regular expression object.
2148
- *
2149
- * ```js
2150
- * util.types.isRegExp(/abc/); // Returns true
2151
- * util.types.isRegExp(new RegExp('abc')); // Returns true
2152
- * ```
2153
- * @since v10.0.0
2154
- */
2155
- function isRegExp(object: unknown): object is RegExp;
2156
- /**
2157
- * Returns `true` if the value is a built-in [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance.
2158
- *
2159
- * ```js
2160
- * util.types.isSet(new Set()); // Returns true
2161
- * ```
2162
- * @since v10.0.0
2163
- */
2164
- function isSet<T>(
2165
- object: T | {},
2166
- ): object is T extends ReadonlySet<any> ? (unknown extends T ? never : ReadonlySet<any>) : Set<unknown>;
2167
- /**
2168
- * Returns `true` if the value is an iterator returned for a built-in [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance.
2169
- *
2170
- * ```js
2171
- * const set = new Set();
2172
- * util.types.isSetIterator(set.keys()); // Returns true
2173
- * util.types.isSetIterator(set.values()); // Returns true
2174
- * util.types.isSetIterator(set.entries()); // Returns true
2175
- * util.types.isSetIterator(set[Symbol.iterator]()); // Returns true
2176
- * ```
2177
- * @since v10.0.0
2178
- */
2179
- function isSetIterator(object: unknown): boolean;
2180
- /**
2181
- * Returns `true` if the value is a built-in [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instance.
2182
- * This does _not_ include [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) instances. Usually, it is
2183
- * desirable to test for both; See `util.types.isAnyArrayBuffer()` for that.
2184
- *
2185
- * ```js
2186
- * util.types.isSharedArrayBuffer(new ArrayBuffer()); // Returns false
2187
- * util.types.isSharedArrayBuffer(new SharedArrayBuffer()); // Returns true
2188
- * ```
2189
- * @since v10.0.0
2190
- */
2191
- function isSharedArrayBuffer(object: unknown): object is SharedArrayBuffer;
2192
- /**
2193
- * Returns `true` if the value is a string object, e.g. created
2194
- * by `new String()`.
2195
- *
2196
- * ```js
2197
- * util.types.isStringObject('foo'); // Returns false
2198
- * util.types.isStringObject(new String('foo')); // Returns true
2199
- * ```
2200
- * @since v10.0.0
2201
- */
2202
- function isStringObject(object: unknown): object is String;
2203
- /**
2204
- * Returns `true` if the value is a symbol object, created
2205
- * by calling `Object()` on a `Symbol` primitive.
2206
- *
2207
- * ```js
2208
- * const symbol = Symbol('foo');
2209
- * util.types.isSymbolObject(symbol); // Returns false
2210
- * util.types.isSymbolObject(Object(symbol)); // Returns true
2211
- * ```
2212
- * @since v10.0.0
2213
- */
2214
- function isSymbolObject(object: unknown): object is Symbol;
2215
- /**
2216
- * Returns `true` if the value is a built-in [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) instance.
2217
- *
2218
- * ```js
2219
- * util.types.isTypedArray(new ArrayBuffer()); // Returns false
2220
- * util.types.isTypedArray(new Uint8Array()); // Returns true
2221
- * util.types.isTypedArray(new Float64Array()); // Returns true
2222
- * ```
2223
- *
2224
- * See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
2225
- * @since v10.0.0
2226
- */
2227
- function isTypedArray(object: unknown): object is NodeJS.TypedArray;
2228
- /**
2229
- * Returns `true` if the value is a built-in [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) instance.
2230
- *
2231
- * ```js
2232
- * util.types.isUint8Array(new ArrayBuffer()); // Returns false
2233
- * util.types.isUint8Array(new Uint8Array()); // Returns true
2234
- * util.types.isUint8Array(new Float64Array()); // Returns false
2235
- * ```
2236
- * @since v10.0.0
2237
- */
2238
- function isUint8Array(object: unknown): object is Uint8Array;
2239
- /**
2240
- * Returns `true` if the value is a built-in [`Uint8ClampedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray) instance.
2241
- *
2242
- * ```js
2243
- * util.types.isUint8ClampedArray(new ArrayBuffer()); // Returns false
2244
- * util.types.isUint8ClampedArray(new Uint8ClampedArray()); // Returns true
2245
- * util.types.isUint8ClampedArray(new Float64Array()); // Returns false
2246
- * ```
2247
- * @since v10.0.0
2248
- */
2249
- function isUint8ClampedArray(object: unknown): object is Uint8ClampedArray;
2250
- /**
2251
- * Returns `true` if the value is a built-in [`Uint16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array) instance.
2252
- *
2253
- * ```js
2254
- * util.types.isUint16Array(new ArrayBuffer()); // Returns false
2255
- * util.types.isUint16Array(new Uint16Array()); // Returns true
2256
- * util.types.isUint16Array(new Float64Array()); // Returns false
2257
- * ```
2258
- * @since v10.0.0
2259
- */
2260
- function isUint16Array(object: unknown): object is Uint16Array;
2261
- /**
2262
- * Returns `true` if the value is a built-in [`Uint32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array) instance.
2263
- *
2264
- * ```js
2265
- * util.types.isUint32Array(new ArrayBuffer()); // Returns false
2266
- * util.types.isUint32Array(new Uint32Array()); // Returns true
2267
- * util.types.isUint32Array(new Float64Array()); // Returns false
2268
- * ```
2269
- * @since v10.0.0
2270
- */
2271
- function isUint32Array(object: unknown): object is Uint32Array;
2272
- /**
2273
- * Returns `true` if the value is a built-in [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) instance.
2274
- *
2275
- * ```js
2276
- * util.types.isWeakMap(new WeakMap()); // Returns true
2277
- * ```
2278
- * @since v10.0.0
2279
- */
2280
- function isWeakMap(object: unknown): object is WeakMap<object, unknown>;
2281
- /**
2282
- * Returns `true` if the value is a built-in [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) instance.
2283
- *
2284
- * ```js
2285
- * util.types.isWeakSet(new WeakSet()); // Returns true
2286
- * ```
2287
- * @since v10.0.0
2288
- */
2289
- function isWeakSet(object: unknown): object is WeakSet<object>;
2290
- /**
2291
- * Returns `true` if `value` is a `KeyObject`, `false` otherwise.
2292
- * @since v16.2.0
2293
- */
2294
- function isKeyObject(object: unknown): object is KeyObject;
2295
- /**
2296
- * Returns `true` if `value` is a `CryptoKey`, `false` otherwise.
2297
- * @since v16.2.0
2298
- */
2299
- function isCryptoKey(object: unknown): object is webcrypto.CryptoKey;
1630
+ // #region web types
1631
+ export interface TextDecodeOptions {
1632
+ stream?: boolean;
1633
+ }
1634
+ export interface TextDecoderCommon {
1635
+ readonly encoding: string;
1636
+ readonly fatal: boolean;
1637
+ readonly ignoreBOM: boolean;
1638
+ }
1639
+ export interface TextDecoderOptions {
1640
+ fatal?: boolean;
1641
+ ignoreBOM?: boolean;
1642
+ }
1643
+ export interface TextEncoderCommon {
1644
+ readonly encoding: string;
1645
+ }
1646
+ export interface TextEncoderEncodeIntoResult {
1647
+ read: number;
1648
+ written: number;
1649
+ }
1650
+ export interface TextDecoder extends TextDecoderCommon {
1651
+ decode(input?: NodeJS.AllowSharedBufferSource, options?: TextDecodeOptions): string;
1652
+ }
1653
+ export var TextDecoder: {
1654
+ prototype: TextDecoder;
1655
+ new(label?: string, options?: TextDecoderOptions): TextDecoder;
1656
+ };
1657
+ export interface TextEncoder extends TextEncoderCommon {
1658
+ encode(input?: string): NodeJS.NonSharedUint8Array;
1659
+ encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult;
1660
+ }
1661
+ export var TextEncoder: {
1662
+ prototype: TextEncoder;
1663
+ new(): TextEncoder;
1664
+ };
1665
+ // #endregion
2300
1666
  }