@idlebox/stripe-node-types 24.0.14-patch.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 (113) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +16 -0
  3. package/assert/strict.d.ts +5 -0
  4. package/assert.d.ts +1053 -0
  5. package/async_hooks.d.ts +621 -0
  6. package/buffer.buffer.d.ts +464 -0
  7. package/buffer.d.ts +1928 -0
  8. package/child_process.d.ts +1547 -0
  9. package/cluster.d.ts +576 -0
  10. package/compatibility/iterators.d.ts +22 -0
  11. package/console.d.ts +449 -0
  12. package/constants.d.ts +18 -0
  13. package/crypto.d.ts +4514 -0
  14. package/dgram.d.ts +597 -0
  15. package/diagnostics_channel.d.ts +576 -0
  16. package/dns/promises.d.ts +501 -0
  17. package/dns.d.ts +916 -0
  18. package/dom-events.d.ts +100 -0
  19. package/domain.d.ts +168 -0
  20. package/events.d.ts +927 -0
  21. package/fs/promises.d.ts +1278 -0
  22. package/fs.d.ts +4444 -0
  23. package/globals.d.ts +368 -0
  24. package/globals.typedarray.d.ts +23 -0
  25. package/http.d.ts +2044 -0
  26. package/http2.d.ts +2626 -0
  27. package/https.d.ts +543 -0
  28. package/index.d.ts +96 -0
  29. package/inspector.d.ts +3993 -0
  30. package/module.d.ts +866 -0
  31. package/my-shim.d.ts +57 -0
  32. package/net.d.ts +1030 -0
  33. package/os.d.ts +494 -0
  34. package/package.json +158 -0
  35. package/path.d.ts +189 -0
  36. package/perf_hooks.d.ts +968 -0
  37. package/process.d.ts +2016 -0
  38. package/punycode.d.ts +115 -0
  39. package/querystring.d.ts +150 -0
  40. package/readline/promises.d.ts +159 -0
  41. package/readline.d.ts +592 -0
  42. package/repl.d.ts +426 -0
  43. package/sea.d.ts +154 -0
  44. package/sqlite.d.ts +689 -0
  45. package/stream/consumers.d.ts +36 -0
  46. package/stream/promises.d.ts +88 -0
  47. package/stream/web.d.ts +616 -0
  48. package/stream.d.ts +1654 -0
  49. package/string_decoder.d.ts +65 -0
  50. package/test.d.ts +2216 -0
  51. package/timers/promises.d.ts +106 -0
  52. package/timers.d.ts +285 -0
  53. package/tls.d.ts +1211 -0
  54. package/trace_events.d.ts +195 -0
  55. package/ts5.1/compatibility/disposable.d.ts +13 -0
  56. package/ts5.1/index.d.ts +100 -0
  57. package/ts5.6/buffer.buffer.d.ts +461 -0
  58. package/ts5.6/compatibility/float16array.d.ts +72 -0
  59. package/ts5.6/globals.typedarray.d.ts +21 -0
  60. package/ts5.6/index.d.ts +98 -0
  61. package/ts5.7/compatibility/float16array.d.ts +73 -0
  62. package/ts5.7/index.d.ts +98 -0
  63. package/tty.d.ts +206 -0
  64. package/undici-types/LICENSE +22 -0
  65. package/undici-types/README.md +7 -0
  66. package/undici-types/agent.d.ts +32 -0
  67. package/undici-types/api.d.ts +44 -0
  68. package/undici-types/balanced-pool.d.ts +30 -0
  69. package/undici-types/cache-interceptor.d.ts +173 -0
  70. package/undici-types/cache.d.ts +37 -0
  71. package/undici-types/client.d.ts +108 -0
  72. package/undici-types/connector.d.ts +35 -0
  73. package/undici-types/content-type.d.ts +22 -0
  74. package/undici-types/cookies.d.ts +31 -0
  75. package/undici-types/diagnostics-channel.d.ts +67 -0
  76. package/undici-types/dispatcher.d.ts +282 -0
  77. package/undici-types/env-http-proxy-agent.d.ts +22 -0
  78. package/undici-types/errors.d.ts +172 -0
  79. package/undici-types/eventsource.d.ts +62 -0
  80. package/undici-types/fetch.d.ts +211 -0
  81. package/undici-types/formdata.d.ts +109 -0
  82. package/undici-types/global-dispatcher.d.ts +10 -0
  83. package/undici-types/global-origin.d.ts +8 -0
  84. package/undici-types/h2c-client.d.ts +76 -0
  85. package/undici-types/handlers.d.ts +16 -0
  86. package/undici-types/header.d.ts +161 -0
  87. package/undici-types/index.d.ts +76 -0
  88. package/undici-types/interceptors.d.ts +35 -0
  89. package/undici-types/mock-agent.d.ts +66 -0
  90. package/undici-types/mock-call-history.d.ts +112 -0
  91. package/undici-types/mock-client.d.ts +26 -0
  92. package/undici-types/mock-errors.d.ts +13 -0
  93. package/undici-types/mock-interceptor.d.ts +94 -0
  94. package/undici-types/mock-pool.d.ts +26 -0
  95. package/undici-types/package.json +55 -0
  96. package/undici-types/patch.d.ts +30 -0
  97. package/undici-types/pool-stats.d.ts +20 -0
  98. package/undici-types/pool.d.ts +40 -0
  99. package/undici-types/proxy-agent.d.ts +29 -0
  100. package/undici-types/readable.d.ts +69 -0
  101. package/undici-types/retry-agent.d.ts +9 -0
  102. package/undici-types/retry-handler.d.ts +117 -0
  103. package/undici-types/util.d.ts +19 -0
  104. package/undici-types/utility.d.ts +8 -0
  105. package/undici-types/webidl.d.ts +267 -0
  106. package/undici-types/websocket.d.ts +185 -0
  107. package/url.d.ts +1012 -0
  108. package/util.d.ts +2300 -0
  109. package/v8.d.ts +917 -0
  110. package/vm.d.ts +1034 -0
  111. package/wasi.d.ts +179 -0
  112. package/worker_threads.d.ts +773 -0
  113. package/zlib.d.ts +666 -0
package/util.d.ts ADDED
@@ -0,0 +1,2300 @@
1
+ /**
2
+ * The `node:util` module supports the needs of Node.js internal APIs. Many of the
3
+ * utilities are useful for application and module developers as well. To access
4
+ * it:
5
+ *
6
+ * ```js
7
+ * import util from 'node:util';
8
+ * ```
9
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/util.js)
10
+ */
11
+
12
+ declare module "node:util" {
13
+ import * as types from 'node:util/types';
14
+ export interface InspectOptions {
15
+ /**
16
+ * If `true`, object's non-enumerable symbols and properties are included in the formatted result.
17
+ * `WeakMap` and `WeakSet` entries are also included as well as user defined prototype properties (excluding method properties).
18
+ * @default false
19
+ */
20
+ showHidden?: boolean | undefined;
21
+ /**
22
+ * Specifies the number of times to recurse while formatting object.
23
+ * This is useful for inspecting large objects.
24
+ * To recurse up to the maximum call stack size pass `Infinity` or `null`.
25
+ * @default 2
26
+ */
27
+ depth?: number | null | undefined;
28
+ /**
29
+ * If `true`, the output is styled with ANSI color codes. Colors are customizable.
30
+ */
31
+ colors?: boolean | undefined;
32
+ /**
33
+ * If `false`, `[util.inspect.custom](depth, opts, inspect)` functions are not invoked.
34
+ * @default true
35
+ */
36
+ customInspect?: boolean | undefined;
37
+ /**
38
+ * If `true`, `Proxy` inspection includes the target and handler objects.
39
+ * @default false
40
+ */
41
+ showProxy?: boolean | undefined;
42
+ /**
43
+ * Specifies the maximum number of `Array`, `TypedArray`, `WeakMap`, and `WeakSet` elements
44
+ * to include when formatting. Set to `null` or `Infinity` to show all elements.
45
+ * Set to `0` or negative to show no elements.
46
+ * @default 100
47
+ */
48
+ maxArrayLength?: number | null | undefined;
49
+ /**
50
+ * Specifies the maximum number of characters to
51
+ * include when formatting. Set to `null` or `Infinity` to show all elements.
52
+ * Set to `0` or negative to show no characters.
53
+ * @default 10000
54
+ */
55
+ maxStringLength?: number | null | undefined;
56
+ /**
57
+ * The length at which input values are split across multiple lines.
58
+ * Set to `Infinity` to format the input as a single line
59
+ * (in combination with `compact` set to `true` or any number >= `1`).
60
+ * @default 80
61
+ */
62
+ breakLength?: number | undefined;
63
+ /**
64
+ * Setting this to `false` causes each object key
65
+ * to be displayed on a new line. It will also add new lines to text that is
66
+ * longer than `breakLength`. If set to a number, the most `n` inner elements
67
+ * are united on a single line as long as all properties fit into
68
+ * `breakLength`. Short array elements are also grouped together. Note that no
69
+ * text will be reduced below 16 characters, no matter the `breakLength` size.
70
+ * For more information, see the example below.
71
+ * @default true
72
+ */
73
+ compact?: boolean | number | undefined;
74
+ /**
75
+ * If set to `true` or a function, all properties of an object, and `Set` and `Map`
76
+ * entries are sorted in the resulting string.
77
+ * If set to `true` the default sort is used.
78
+ * If set to a function, it is used as a compare function.
79
+ */
80
+ sorted?: boolean | ((a: string, b: string) => number) | undefined;
81
+ /**
82
+ * If set to `true`, getters are going to be
83
+ * inspected as well. If set to `'get'` only getters without setter are going
84
+ * to be inspected. If set to `'set'` only getters having a corresponding
85
+ * setter are going to be inspected. This might cause side effects depending on
86
+ * the getter function.
87
+ * @default false
88
+ */
89
+ getters?: "get" | "set" | boolean | undefined;
90
+ /**
91
+ * If set to `true`, an underscore is used to separate every three digits in all bigints and numbers.
92
+ * @default false
93
+ */
94
+ numericSeparator?: boolean | undefined;
95
+ }
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;
111
+ }
112
+ export interface CallSiteObject {
113
+ /**
114
+ * Returns the name of the function associated with this call site.
115
+ */
116
+ functionName: string;
117
+ /**
118
+ * Returns the name of the resource that contains the script for the
119
+ * function for this call site.
120
+ */
121
+ scriptName: string;
122
+ /**
123
+ * Returns the unique id of the script, as in Chrome DevTools protocol
124
+ * [`Runtime.ScriptId`](https://chromedevtools.github.io/devtools-protocol/1-3/Runtime/#type-ScriptId).
125
+ * @since v22.14.0
126
+ */
127
+ scriptId: string;
128
+ /**
129
+ * Returns the number, 1-based, of the line for the associate function call.
130
+ */
131
+ lineNumber: number;
132
+ /**
133
+ * Returns the 1-based column offset on the line for the associated function call.
134
+ */
135
+ columnNumber: number;
136
+ }
137
+ export type DiffEntry = [operation: -1 | 0 | 1, value: string];
138
+ /**
139
+ * `util.diff()` compares two string or array values and returns an array of difference entries.
140
+ * It uses the Myers diff algorithm to compute minimal differences, which is the same algorithm
141
+ * used internally by assertion error messages.
142
+ *
143
+ * If the values are equal, an empty array is returned.
144
+ *
145
+ * ```js
146
+ * const { diff } = require('node:util');
147
+ *
148
+ * // Comparing strings
149
+ * const actualString = '12345678';
150
+ * const expectedString = '12!!5!7!';
151
+ * console.log(diff(actualString, expectedString));
152
+ * // [
153
+ * // [0, '1'],
154
+ * // [0, '2'],
155
+ * // [1, '3'],
156
+ * // [1, '4'],
157
+ * // [-1, '!'],
158
+ * // [-1, '!'],
159
+ * // [0, '5'],
160
+ * // [1, '6'],
161
+ * // [-1, '!'],
162
+ * // [0, '7'],
163
+ * // [1, '8'],
164
+ * // [-1, '!'],
165
+ * // ]
166
+ * // Comparing arrays
167
+ * const actualArray = ['1', '2', '3'];
168
+ * const expectedArray = ['1', '3', '4'];
169
+ * console.log(diff(actualArray, expectedArray));
170
+ * // [
171
+ * // [0, '1'],
172
+ * // [1, '2'],
173
+ * // [0, '3'],
174
+ * // [-1, '4'],
175
+ * // ]
176
+ * // Equal values return empty array
177
+ * console.log(diff('same', 'same'));
178
+ * // []
179
+ * ```
180
+ * @since v22.15.0
181
+ * @experimental
182
+ * @param actual The first value to compare
183
+ * @param expected The second value to compare
184
+ * @returns An array of difference entries. Each entry is an array with two elements:
185
+ * * Index 0: `number` Operation code: `-1` for delete, `0` for no-op/unchanged, `1` for insert
186
+ * * Index 1: `string` The value associated with the operation
187
+ */
188
+ export function diff(actual: string | readonly string[], expected: string | readonly string[]): DiffEntry[];
189
+ /**
190
+ * The `util.format()` method returns a formatted string using the first argument
191
+ * as a `printf`-like format string which can contain zero or more format
192
+ * specifiers. Each specifier is replaced with the converted value from the
193
+ * corresponding argument. Supported specifiers are:
194
+ *
195
+ * If a specifier does not have a corresponding argument, it is not replaced:
196
+ *
197
+ * ```js
198
+ * util.format('%s:%s', 'foo');
199
+ * // Returns: 'foo:%s'
200
+ * ```
201
+ *
202
+ * Values that are not part of the format string are formatted using `util.inspect()` if their type is not `string`.
203
+ *
204
+ * If there are more arguments passed to the `util.format()` method than the
205
+ * number of specifiers, the extra arguments are concatenated to the returned
206
+ * string, separated by spaces:
207
+ *
208
+ * ```js
209
+ * util.format('%s:%s', 'foo', 'bar', 'baz');
210
+ * // Returns: 'foo:bar baz'
211
+ * ```
212
+ *
213
+ * If the first argument does not contain a valid format specifier, `util.format()` returns a string that is the concatenation of all arguments separated by spaces:
214
+ *
215
+ * ```js
216
+ * util.format(1, 2, 3);
217
+ * // Returns: '1 2 3'
218
+ * ```
219
+ *
220
+ * If only one argument is passed to `util.format()`, it is returned as it is
221
+ * without any formatting:
222
+ *
223
+ * ```js
224
+ * util.format('%% %s');
225
+ * // Returns: '%% %s'
226
+ * ```
227
+ *
228
+ * `util.format()` is a synchronous method that is intended as a debugging tool.
229
+ * Some input values can have a significant performance overhead that can block the
230
+ * event loop. Use this function with care and never in a hot code path.
231
+ * @since v0.5.3
232
+ * @param format A `printf`-like format string.
233
+ */
234
+ export function format(format?: any, ...param: any[]): string;
235
+ /**
236
+ * This function is identical to {@link format}, except in that it takes
237
+ * an `inspectOptions` argument which specifies options that are passed along to {@link inspect}.
238
+ *
239
+ * ```js
240
+ * util.formatWithOptions({ colors: true }, 'See object %O', { foo: 42 });
241
+ * // Returns 'See object { foo: 42 }', where `42` is colored as a number
242
+ * // when printed to a terminal.
243
+ * ```
244
+ * @since v10.0.0
245
+ */
246
+ export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string;
247
+ interface GetCallSitesOptions {
248
+ /**
249
+ * Reconstruct the original location in the stacktrace from the source-map.
250
+ * Enabled by default with the flag `--enable-source-maps`.
251
+ */
252
+ sourceMap?: boolean | undefined;
253
+ }
254
+ /**
255
+ * Returns an array of call site objects containing the stack of
256
+ * the caller function.
257
+ *
258
+ * ```js
259
+ * import { getCallSites } from 'node:util';
260
+ *
261
+ * function exampleFunction() {
262
+ * const callSites = getCallSites();
263
+ *
264
+ * console.log('Call Sites:');
265
+ * callSites.forEach((callSite, index) => {
266
+ * console.log(`CallSite ${index + 1}:`);
267
+ * console.log(`Function Name: ${callSite.functionName}`);
268
+ * console.log(`Script Name: ${callSite.scriptName}`);
269
+ * console.log(`Line Number: ${callSite.lineNumber}`);
270
+ * console.log(`Column Number: ${callSite.column}`);
271
+ * });
272
+ * // CallSite 1:
273
+ * // Function Name: exampleFunction
274
+ * // Script Name: /home/example.js
275
+ * // Line Number: 5
276
+ * // Column Number: 26
277
+ *
278
+ * // CallSite 2:
279
+ * // Function Name: anotherFunction
280
+ * // Script Name: /home/example.js
281
+ * // Line Number: 22
282
+ * // Column Number: 3
283
+ *
284
+ * // ...
285
+ * }
286
+ *
287
+ * // A function to simulate another stack layer
288
+ * function anotherFunction() {
289
+ * exampleFunction();
290
+ * }
291
+ *
292
+ * anotherFunction();
293
+ * ```
294
+ *
295
+ * It is possible to reconstruct the original locations by setting the option `sourceMap` to `true`.
296
+ * If the source map is not available, the original location will be the same as the current location.
297
+ * When the `--enable-source-maps` flag is enabled, for example when using `--experimental-transform-types`,
298
+ * `sourceMap` will be true by default.
299
+ *
300
+ * ```ts
301
+ * import { getCallSites } from 'node:util';
302
+ *
303
+ * interface Foo {
304
+ * foo: string;
305
+ * }
306
+ *
307
+ * const callSites = getCallSites({ sourceMap: true });
308
+ *
309
+ * // With sourceMap:
310
+ * // Function Name: ''
311
+ * // Script Name: example.js
312
+ * // Line Number: 7
313
+ * // Column Number: 26
314
+ *
315
+ * // Without sourceMap:
316
+ * // Function Name: ''
317
+ * // Script Name: example.js
318
+ * // Line Number: 2
319
+ * // Column Number: 26
320
+ * ```
321
+ * @param frameCount Number of frames to capture as call site objects.
322
+ * **Default:** `10`. Allowable range is between 1 and 200.
323
+ * @return An array of call site objects
324
+ * @since v22.9.0
325
+ */
326
+ export function getCallSites(frameCount?: number, options?: GetCallSitesOptions): CallSiteObject[];
327
+ export function getCallSites(options: GetCallSitesOptions): CallSiteObject[];
328
+ /**
329
+ * Returns the string name for a numeric error code that comes from a Node.js API.
330
+ * The mapping between error codes and error names is platform-dependent.
331
+ * See `Common System Errors` for the names of common errors.
332
+ *
333
+ * ```js
334
+ * fs.access('file/that/does/not/exist', (err) => {
335
+ * const name = util.getSystemErrorName(err.errno);
336
+ * console.error(name); // ENOENT
337
+ * });
338
+ * ```
339
+ * @since v9.7.0
340
+ */
341
+ export function getSystemErrorName(err: number): string;
342
+ /**
343
+ * Returns a Map of all system error codes available from the Node.js API.
344
+ * The mapping between error codes and error names is platform-dependent.
345
+ * See `Common System Errors` for the names of common errors.
346
+ *
347
+ * ```js
348
+ * fs.access('file/that/does/not/exist', (err) => {
349
+ * const errorMap = util.getSystemErrorMap();
350
+ * const name = errorMap.get(err.errno);
351
+ * console.error(name); // ENOENT
352
+ * });
353
+ * ```
354
+ * @since v16.0.0, v14.17.0
355
+ */
356
+ export function getSystemErrorMap(): Map<number, [string, string]>;
357
+ /**
358
+ * Returns the string message for a numeric error code that comes from a Node.js
359
+ * API.
360
+ * The mapping between error codes and string messages is platform-dependent.
361
+ *
362
+ * ```js
363
+ * fs.access('file/that/does/not/exist', (err) => {
364
+ * const message = util.getSystemErrorMessage(err.errno);
365
+ * console.error(message); // no such file or directory
366
+ * });
367
+ * ```
368
+ * @since v22.12.0
369
+ */
370
+ export function getSystemErrorMessage(err: number): string;
371
+ /**
372
+ * Returns the `string` after replacing any surrogate code points
373
+ * (or equivalently, any unpaired surrogate code units) with the
374
+ * Unicode "replacement character" U+FFFD.
375
+ * @since v16.8.0, v14.18.0
376
+ */
377
+ export function toUSVString(string: string): string;
378
+ /**
379
+ * Creates and returns an `AbortController` instance whose `AbortSignal` is marked
380
+ * as transferable and can be used with `structuredClone()` or `postMessage()`.
381
+ * @since v18.11.0
382
+ * @returns A transferable AbortController
383
+ */
384
+ export function transferableAbortController(): AbortController;
385
+ /**
386
+ * Marks the given `AbortSignal` as transferable so that it can be used with`structuredClone()` and `postMessage()`.
387
+ *
388
+ * ```js
389
+ * const signal = transferableAbortSignal(AbortSignal.timeout(100));
390
+ * const channel = new MessageChannel();
391
+ * channel.port2.postMessage(signal, [signal]);
392
+ * ```
393
+ * @since v18.11.0
394
+ * @param signal The AbortSignal
395
+ * @returns The same AbortSignal
396
+ */
397
+ export function transferableAbortSignal(signal: AbortSignal): AbortSignal;
398
+ /**
399
+ * Listens to abort event on the provided `signal` and returns a promise that resolves when the `signal` is aborted.
400
+ * If `resource` is provided, it weakly references the operation's associated object,
401
+ * so if `resource` is garbage collected before the `signal` aborts,
402
+ * then returned promise shall remain pending.
403
+ * This prevents memory leaks in long-running or non-cancelable operations.
404
+ *
405
+ * ```js
406
+ * import { aborted } from 'node:util';
407
+ *
408
+ * // Obtain an object with an abortable signal, like a custom resource or operation.
409
+ * const dependent = obtainSomethingAbortable();
410
+ *
411
+ * // Pass `dependent` as the resource, indicating the promise should only resolve
412
+ * // if `dependent` is still in memory when the signal is aborted.
413
+ * aborted(dependent.signal, dependent).then(() => {
414
+ * // This code runs when `dependent` is aborted.
415
+ * console.log('Dependent resource was aborted.');
416
+ * });
417
+ *
418
+ * // Simulate an event that triggers the abort.
419
+ * dependent.on('event', () => {
420
+ * dependent.abort(); // This will cause the `aborted` promise to resolve.
421
+ * });
422
+ * ```
423
+ * @since v19.7.0
424
+ * @param resource Any non-null object tied to the abortable operation and held weakly.
425
+ * If `resource` is garbage collected before the `signal` aborts, the promise remains pending,
426
+ * allowing Node.js to stop tracking it.
427
+ * This helps prevent memory leaks in long-running or non-cancelable operations.
428
+ */
429
+ export function aborted(signal: AbortSignal, resource: any): Promise<void>;
430
+ /**
431
+ * The `util.inspect()` method returns a string representation of `object` that is
432
+ * intended for debugging. The output of `util.inspect` may change at any time
433
+ * and should not be depended upon programmatically. Additional `options` may be
434
+ * 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.
437
+ *
438
+ * ```js
439
+ * class Foo {
440
+ * get [Symbol.toStringTag]() {
441
+ * return 'bar';
442
+ * }
443
+ * }
444
+ *
445
+ * class Bar {}
446
+ *
447
+ * const baz = Object.create(null, { [Symbol.toStringTag]: { value: 'foo' } });
448
+ *
449
+ * util.inspect(new Foo()); // 'Foo [bar] {}'
450
+ * util.inspect(new Bar()); // 'Bar {}'
451
+ * util.inspect(baz); // '[foo] {}'
452
+ * ```
453
+ *
454
+ * Circular references point to their anchor by using a reference index:
455
+ *
456
+ * ```js
457
+ * import { inspect } from 'node:util';
458
+ *
459
+ * const obj = {};
460
+ * obj.a = [obj];
461
+ * obj.b = {};
462
+ * obj.b.inner = obj.b;
463
+ * obj.b.obj = obj;
464
+ *
465
+ * console.log(inspect(obj));
466
+ * // <ref *1> {
467
+ * // a: [ [Circular *1] ],
468
+ * // b: <ref *2> { inner: [Circular *2], obj: [Circular *1] }
469
+ * // }
470
+ * ```
471
+ *
472
+ * The following example inspects all properties of the `util` object:
473
+ *
474
+ * ```js
475
+ * import util from 'node:util';
476
+ *
477
+ * console.log(util.inspect(util, { showHidden: true, depth: null }));
478
+ * ```
479
+ *
480
+ * The following example highlights the effect of the `compact` option:
481
+ *
482
+ * ```js
483
+ * import { inspect } from 'node:util';
484
+ *
485
+ * const o = {
486
+ * a: [1, 2, [[
487
+ * 'Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit, sed do ' +
488
+ * 'eiusmod \ntempor incididunt ut labore et dolore magna aliqua.',
489
+ * 'test',
490
+ * 'foo']], 4],
491
+ * b: new Map([['za', 1], ['zb', 'test']]),
492
+ * };
493
+ * console.log(inspect(o, { compact: true, depth: 5, breakLength: 80 }));
494
+ *
495
+ * // { a:
496
+ * // [ 1,
497
+ * // 2,
498
+ * // [ [ 'Lorem ipsum dolor sit amet,\nconsectetur [...]', // A long line
499
+ * // 'test',
500
+ * // 'foo' ] ],
501
+ * // 4 ],
502
+ * // b: Map(2) { 'za' => 1, 'zb' => 'test' } }
503
+ *
504
+ * // Setting `compact` to false or an integer creates more reader friendly output.
505
+ * console.log(inspect(o, { compact: false, depth: 5, breakLength: 80 }));
506
+ *
507
+ * // {
508
+ * // a: [
509
+ * // 1,
510
+ * // 2,
511
+ * // [
512
+ * // [
513
+ * // 'Lorem ipsum dolor sit amet,\n' +
514
+ * // 'consectetur adipiscing elit, sed do eiusmod \n' +
515
+ * // 'tempor incididunt ut labore et dolore magna aliqua.',
516
+ * // 'test',
517
+ * // 'foo'
518
+ * // ]
519
+ * // ],
520
+ * // 4
521
+ * // ],
522
+ * // b: Map(2) {
523
+ * // 'za' => 1,
524
+ * // 'zb' => 'test'
525
+ * // }
526
+ * // }
527
+ *
528
+ * // Setting `breakLength` to e.g. 150 will print the "Lorem ipsum" text in a
529
+ * // single line.
530
+ * ```
531
+ *
532
+ * The `showHidden` option allows `WeakMap` and `WeakSet` entries to be
533
+ * inspected. If there are more entries than `maxArrayLength`, there is no
534
+ * guarantee which entries are displayed. That means retrieving the same
535
+ * `WeakSet` entries twice may result in different output. Furthermore, entries
536
+ * with no remaining strong references may be garbage collected at any time.
537
+ *
538
+ * ```js
539
+ * import { inspect } from 'node:util';
540
+ *
541
+ * const obj = { a: 1 };
542
+ * const obj2 = { b: 2 };
543
+ * const weakSet = new WeakSet([obj, obj2]);
544
+ *
545
+ * console.log(inspect(weakSet, { showHidden: true }));
546
+ * // WeakSet { { a: 1 }, { b: 2 } }
547
+ * ```
548
+ *
549
+ * The `sorted` option ensures that an object's property insertion order does not
550
+ * impact the result of `util.inspect()`.
551
+ *
552
+ * ```js
553
+ * import { inspect } from 'node:util';
554
+ * import assert from 'node:assert';
555
+ *
556
+ * const o1 = {
557
+ * b: [2, 3, 1],
558
+ * a: '`a` comes before `b`',
559
+ * c: new Set([2, 3, 1]),
560
+ * };
561
+ * console.log(inspect(o1, { sorted: true }));
562
+ * // { a: '`a` comes before `b`', b: [ 2, 3, 1 ], c: Set(3) { 1, 2, 3 } }
563
+ * console.log(inspect(o1, { sorted: (a, b) => b.localeCompare(a) }));
564
+ * // { c: Set(3) { 3, 2, 1 }, b: [ 2, 3, 1 ], a: '`a` comes before `b`' }
565
+ *
566
+ * const o2 = {
567
+ * c: new Set([2, 1, 3]),
568
+ * a: '`a` comes before `b`',
569
+ * b: [2, 3, 1],
570
+ * };
571
+ * assert.strict.equal(
572
+ * inspect(o1, { sorted: true }),
573
+ * inspect(o2, { sorted: true }),
574
+ * );
575
+ * ```
576
+ *
577
+ * The `numericSeparator` option adds an underscore every three digits to all
578
+ * numbers.
579
+ *
580
+ * ```js
581
+ * import { inspect } from 'node:util';
582
+ *
583
+ * const thousand = 1000;
584
+ * const million = 1000000;
585
+ * const bigNumber = 123456789n;
586
+ * const bigDecimal = 1234.12345;
587
+ *
588
+ * console.log(inspect(thousand, { numericSeparator: true }));
589
+ * // 1_000
590
+ * console.log(inspect(million, { numericSeparator: true }));
591
+ * // 1_000_000
592
+ * console.log(inspect(bigNumber, { numericSeparator: true }));
593
+ * // 123_456_789n
594
+ * console.log(inspect(bigDecimal, { numericSeparator: true }));
595
+ * // 1_234.123_45
596
+ * ```
597
+ *
598
+ * `util.inspect()` is a synchronous method intended for debugging. Its maximum
599
+ * output length is approximately 128 MiB. Inputs that result in longer output will
600
+ * be truncated.
601
+ * @since v0.3.0
602
+ * @param object Any JavaScript primitive or `Object`.
603
+ * @return The representation of `object`.
604
+ */
605
+ export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
606
+ export function inspect(object: any, options?: InspectOptions): string;
607
+ export namespace inspect {
608
+ let colors: NodeJS.Dict<[number, number]>;
609
+ let styles: {
610
+ [K in Style]: string;
611
+ };
612
+ let defaultOptions: InspectOptions;
613
+ /**
614
+ * Allows changing inspect settings from the repl.
615
+ */
616
+ let replDefaults: InspectOptions;
617
+ /**
618
+ * That can be used to declare custom inspect functions.
619
+ */
620
+ const custom: unique symbol;
621
+ }
622
+ /**
623
+ * Alias for [`Array.isArray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray).
624
+ *
625
+ * Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`.
626
+ *
627
+ * ```js
628
+ * import util from 'node:util';
629
+ *
630
+ * util.isArray([]);
631
+ * // Returns: true
632
+ * util.isArray(new Array());
633
+ * // Returns: true
634
+ * util.isArray({});
635
+ * // Returns: false
636
+ * ```
637
+ * @since v0.6.0
638
+ * @deprecated Since v4.0.0 - Use `isArray` instead.
639
+ */
640
+ export function isArray(object: unknown): object is unknown[];
641
+ /**
642
+ * Usage of `util.inherits()` is discouraged. Please use the ES6 `class` and
643
+ * `extends` keywords to get language level inheritance support. Also note
644
+ * that the two styles are [semantically incompatible](https://github.com/nodejs/node/issues/4179).
645
+ *
646
+ * Inherit the prototype methods from one
647
+ * [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor) into another. The
648
+ * prototype of `constructor` will be set to a new object created from
649
+ * `superConstructor`.
650
+ *
651
+ * This mainly adds some input validation on top of
652
+ * `Object.setPrototypeOf(constructor.prototype, superConstructor.prototype)`.
653
+ * As an additional convenience, `superConstructor` will be accessible
654
+ * through the `constructor.super_` property.
655
+ *
656
+ * ```js
657
+ * const util = require('node:util');
658
+ * const EventEmitter = require('node:events');
659
+ *
660
+ * function MyStream() {
661
+ * EventEmitter.call(this);
662
+ * }
663
+ *
664
+ * util.inherits(MyStream, EventEmitter);
665
+ *
666
+ * MyStream.prototype.write = function(data) {
667
+ * this.emit('data', data);
668
+ * };
669
+ *
670
+ * const stream = new MyStream();
671
+ *
672
+ * console.log(stream instanceof EventEmitter); // true
673
+ * console.log(MyStream.super_ === EventEmitter); // true
674
+ *
675
+ * stream.on('data', (data) => {
676
+ * console.log(`Received data: "${data}"`);
677
+ * });
678
+ * stream.write('It works!'); // Received data: "It works!"
679
+ * ```
680
+ *
681
+ * ES6 example using `class` and `extends`:
682
+ *
683
+ * ```js
684
+ * import EventEmitter from 'node:events';
685
+ *
686
+ * class MyStream extends EventEmitter {
687
+ * write(data) {
688
+ * this.emit('data', data);
689
+ * }
690
+ * }
691
+ *
692
+ * const stream = new MyStream();
693
+ *
694
+ * stream.on('data', (data) => {
695
+ * console.log(`Received data: "${data}"`);
696
+ * });
697
+ * stream.write('With ES6');
698
+ * ```
699
+ * @since v0.3.0
700
+ * @legacy Use ES2015 class syntax and `extends` keyword instead.
701
+ */
702
+ export function inherits(constructor: unknown, superConstructor: unknown): void;
703
+ export type DebugLoggerFunction = (msg: string, ...param: unknown[]) => void;
704
+ export interface DebugLogger extends DebugLoggerFunction {
705
+ /**
706
+ * The `util.debuglog().enabled` getter is used to create a test that can be used
707
+ * in conditionals based on the existence of the `NODE_DEBUG` environment variable.
708
+ * If the `section` name appears within the value of that environment variable,
709
+ * then the returned value will be `true`. If not, then the returned value will be
710
+ * `false`.
711
+ *
712
+ * ```js
713
+ * import { debuglog } from 'node:util';
714
+ * const enabled = debuglog('foo').enabled;
715
+ * if (enabled) {
716
+ * console.log('hello from foo [%d]', 123);
717
+ * }
718
+ * ```
719
+ *
720
+ * If this program is run with `NODE_DEBUG=foo` in the environment, then it will
721
+ * output something like:
722
+ *
723
+ * ```console
724
+ * hello from foo [123]
725
+ * ```
726
+ */
727
+ enabled: boolean;
728
+ }
729
+ /**
730
+ * The `util.debuglog()` method is used to create a function that conditionally
731
+ * writes debug messages to `stderr` based on the existence of the `NODE_DEBUG`
732
+ * environment variable. If the `section` name appears within the value of that
733
+ * environment variable, then the returned function operates similar to
734
+ * `console.error()`. If not, then the returned function is a no-op.
735
+ *
736
+ * ```js
737
+ * import { debuglog } from 'node:util';
738
+ * const log = debuglog('foo');
739
+ *
740
+ * log('hello from foo [%d]', 123);
741
+ * ```
742
+ *
743
+ * If this program is run with `NODE_DEBUG=foo` in the environment, then
744
+ * it will output something like:
745
+ *
746
+ * ```console
747
+ * FOO 3245: hello from foo [123]
748
+ * ```
749
+ *
750
+ * where `3245` is the process id. If it is not run with that
751
+ * environment variable set, then it will not print anything.
752
+ *
753
+ * The `section` supports wildcard also:
754
+ *
755
+ * ```js
756
+ * import { debuglog } from 'node:util';
757
+ * const log = debuglog('foo');
758
+ *
759
+ * log('hi there, it\'s foo-bar [%d]', 2333);
760
+ * ```
761
+ *
762
+ * if it is run with `NODE_DEBUG=foo*` in the environment, then it will output
763
+ * something like:
764
+ *
765
+ * ```console
766
+ * FOO-BAR 3257: hi there, it's foo-bar [2333]
767
+ * ```
768
+ *
769
+ * Multiple comma-separated `section` names may be specified in the `NODE_DEBUG`
770
+ * environment variable: `NODE_DEBUG=fs,net,tls`.
771
+ *
772
+ * The optional `callback` argument can be used to replace the logging function
773
+ * with a different function that doesn't have any initialization or
774
+ * unnecessary wrapping.
775
+ *
776
+ * ```js
777
+ * import { debuglog } from 'node:util';
778
+ * let log = debuglog('internals', (debug) => {
779
+ * // Replace with a logging function that optimizes out
780
+ * // testing if the section is enabled
781
+ * log = debug;
782
+ * });
783
+ * ```
784
+ * @since v0.11.3
785
+ * @param section A string identifying the portion of the application for which the `debuglog` function is being created.
786
+ * @param callback A callback invoked the first time the logging function is called with a function argument that is a more optimized logging function.
787
+ * @return The logging function
788
+ */
789
+ export function debuglog(section: string, callback?: (fn: DebugLoggerFunction) => void): DebugLogger;
790
+ export { debuglog as debug };
791
+ /**
792
+ * The `util.deprecate()` method wraps `fn` (which may be a function or class) in
793
+ * such a way that it is marked as deprecated.
794
+ *
795
+ * ```js
796
+ * import { deprecate } from 'node:util';
797
+ *
798
+ * export const obsoleteFunction = deprecate(() => {
799
+ * // Do something here.
800
+ * }, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.');
801
+ * ```
802
+ *
803
+ * When called, `util.deprecate()` will return a function that will emit a
804
+ * `DeprecationWarning` using the `'warning'` event. The warning will
805
+ * be emitted and printed to `stderr` the first time the returned function is
806
+ * called. After the warning is emitted, the wrapped function is called without
807
+ * emitting a warning.
808
+ *
809
+ * If the same optional `code` is supplied in multiple calls to `util.deprecate()`,
810
+ * the warning will be emitted only once for that `code`.
811
+ *
812
+ * ```js
813
+ * import { deprecate } from 'node:util';
814
+ *
815
+ * const fn1 = deprecate(
816
+ * () => 'a value',
817
+ * 'deprecation message',
818
+ * 'DEP0001',
819
+ * );
820
+ * const fn2 = deprecate(
821
+ * () => 'a different value',
822
+ * 'other dep message',
823
+ * 'DEP0001',
824
+ * );
825
+ * fn1(); // Emits a deprecation warning with code DEP0001
826
+ * fn2(); // Does not emit a deprecation warning because it has the same code
827
+ * ```
828
+ *
829
+ * If either the `--no-deprecation` or `--no-warnings` command-line flags are
830
+ * used, or if the `process.noDeprecation` property is set to `true` _prior_ to
831
+ * the first deprecation warning, the `util.deprecate()` method does nothing.
832
+ *
833
+ * If the `--trace-deprecation` or `--trace-warnings` command-line flags are set,
834
+ * or the `process.traceDeprecation` property is set to `true`, a warning and a
835
+ * stack trace are printed to `stderr` the first time the deprecated function is
836
+ * called.
837
+ *
838
+ * If the `--throw-deprecation` command-line flag is set, or the
839
+ * `process.throwDeprecation` property is set to `true`, then an exception will be
840
+ * thrown when the deprecated function is called.
841
+ *
842
+ * The `--throw-deprecation` command-line flag and `process.throwDeprecation`
843
+ * property take precedence over `--trace-deprecation` and
844
+ * `process.traceDeprecation`.
845
+ * @since v0.8.0
846
+ * @param fn The function that is being deprecated.
847
+ * @param msg A warning message to display when the deprecated function is invoked.
848
+ * @param code A deprecation code. See the `list of deprecated APIs` for a list of codes.
849
+ * @return The deprecated function wrapped to emit a warning.
850
+ */
851
+ export function deprecate<T extends Function>(fn: T, msg: string, code?: string): T;
852
+ /**
853
+ * Returns `true` if there is deep strict equality between `val1` and `val2`.
854
+ * Otherwise, returns `false`.
855
+ *
856
+ * See `assert.deepStrictEqual()` for more information about deep strict
857
+ * equality.
858
+ * @since v9.0.0
859
+ */
860
+ export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean;
861
+ /**
862
+ * Returns `str` with any ANSI escape codes removed.
863
+ *
864
+ * ```js
865
+ * console.log(util.stripVTControlCharacters('\u001B[4mvalue\u001B[0m'));
866
+ * // Prints "value"
867
+ * ```
868
+ * @since v16.11.0
869
+ */
870
+ export function stripVTControlCharacters(str: string): string;
871
+ /**
872
+ * Takes an `async` function (or a function that returns a `Promise`) and returns a
873
+ * function following the error-first callback style, i.e. taking
874
+ * an `(err, value) => ...` callback as the last argument. In the callback, the
875
+ * first argument will be the rejection reason (or `null` if the `Promise`
876
+ * resolved), and the second argument will be the resolved value.
877
+ *
878
+ * ```js
879
+ * import { callbackify } from 'node:util';
880
+ *
881
+ * async function fn() {
882
+ * return 'hello world';
883
+ * }
884
+ * const callbackFunction = callbackify(fn);
885
+ *
886
+ * callbackFunction((err, ret) => {
887
+ * if (err) throw err;
888
+ * console.log(ret);
889
+ * });
890
+ * ```
891
+ *
892
+ * Will print:
893
+ *
894
+ * ```text
895
+ * hello world
896
+ * ```
897
+ *
898
+ * The callback is executed asynchronously, and will have a limited stack trace.
899
+ * If the callback throws, the process will emit an `'uncaughtException'`
900
+ * event, and if not handled will exit.
901
+ *
902
+ * Since `null` has a special meaning as the first argument to a callback, if a
903
+ * wrapped function rejects a `Promise` with a falsy value as a reason, the value
904
+ * is wrapped in an `Error` with the original value stored in a field named
905
+ * `reason`.
906
+ *
907
+ * ```js
908
+ * function fn() {
909
+ * return Promise.reject(null);
910
+ * }
911
+ * const callbackFunction = util.callbackify(fn);
912
+ *
913
+ * callbackFunction((err, ret) => {
914
+ * // When the Promise was rejected with `null` it is wrapped with an Error and
915
+ * // the original value is stored in `reason`.
916
+ * err && Object.hasOwn(err, 'reason') && err.reason === null; // true
917
+ * });
918
+ * ```
919
+ * @since v8.2.0
920
+ * @param fn An `async` function
921
+ * @return a callback style function
922
+ */
923
+ export function callbackify(fn: () => Promise<void>): (callback: (err: NodeJS.ErrnoException) => void) => void;
924
+ export function callbackify<TResult>(
925
+ fn: () => Promise<TResult>,
926
+ ): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
927
+ export function callbackify<T1>(
928
+ fn: (arg1: T1) => Promise<void>,
929
+ ): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void;
930
+ export function callbackify<T1, TResult>(
931
+ fn: (arg1: T1) => Promise<TResult>,
932
+ ): (arg1: T1, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
933
+ export function callbackify<T1, T2>(
934
+ fn: (arg1: T1, arg2: T2) => Promise<void>,
935
+ ): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void;
936
+ export function callbackify<T1, T2, TResult>(
937
+ fn: (arg1: T1, arg2: T2) => Promise<TResult>,
938
+ ): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
939
+ export function callbackify<T1, T2, T3>(
940
+ fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<void>,
941
+ ): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void;
942
+ export function callbackify<T1, T2, T3, TResult>(
943
+ fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>,
944
+ ): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
945
+ export function callbackify<T1, T2, T3, T4>(
946
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>,
947
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
948
+ export function callbackify<T1, T2, T3, T4, TResult>(
949
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>,
950
+ ): (
951
+ arg1: T1,
952
+ arg2: T2,
953
+ arg3: T3,
954
+ arg4: T4,
955
+ callback: (err: NodeJS.ErrnoException | null, result: TResult) => void,
956
+ ) => void;
957
+ export function callbackify<T1, T2, T3, T4, T5>(
958
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>,
959
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
960
+ export function callbackify<T1, T2, T3, T4, T5, TResult>(
961
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>,
962
+ ): (
963
+ arg1: T1,
964
+ arg2: T2,
965
+ arg3: T3,
966
+ arg4: T4,
967
+ arg5: T5,
968
+ callback: (err: NodeJS.ErrnoException | null, result: TResult) => void,
969
+ ) => void;
970
+ export function callbackify<T1, T2, T3, T4, T5, T6>(
971
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<void>,
972
+ ): (
973
+ arg1: T1,
974
+ arg2: T2,
975
+ arg3: T3,
976
+ arg4: T4,
977
+ arg5: T5,
978
+ arg6: T6,
979
+ callback: (err: NodeJS.ErrnoException) => void,
980
+ ) => void;
981
+ export function callbackify<T1, T2, T3, T4, T5, T6, TResult>(
982
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<TResult>,
983
+ ): (
984
+ arg1: T1,
985
+ arg2: T2,
986
+ arg3: T3,
987
+ arg4: T4,
988
+ arg5: T5,
989
+ arg6: T6,
990
+ callback: (err: NodeJS.ErrnoException | null, result: TResult) => void,
991
+ ) => void;
992
+ export interface CustomPromisifyLegacy<TCustom extends Function> extends Function {
993
+ __promisify__: TCustom;
994
+ }
995
+ export interface CustomPromisifySymbol<TCustom extends Function> extends Function {
996
+ [promisify.custom]: TCustom;
997
+ }
998
+ export type CustomPromisify<TCustom extends Function> =
999
+ | CustomPromisifySymbol<TCustom>
1000
+ | CustomPromisifyLegacy<TCustom>;
1001
+ /**
1002
+ * Takes a function following the common error-first callback style, i.e. taking
1003
+ * an `(err, value) => ...` callback as the last argument, and returns a version
1004
+ * that returns promises.
1005
+ *
1006
+ * ```js
1007
+ * import { promisify } from 'node:util';
1008
+ * import { stat } from 'node:fs';
1009
+ *
1010
+ * const promisifiedStat = promisify(stat);
1011
+ * promisifiedStat('.').then((stats) => {
1012
+ * // Do something with `stats`
1013
+ * }).catch((error) => {
1014
+ * // Handle the error.
1015
+ * });
1016
+ * ```
1017
+ *
1018
+ * Or, equivalently using `async function`s:
1019
+ *
1020
+ * ```js
1021
+ * import { promisify } from 'node:util';
1022
+ * import { stat } from 'node:fs';
1023
+ *
1024
+ * const promisifiedStat = promisify(stat);
1025
+ *
1026
+ * async function callStat() {
1027
+ * const stats = await promisifiedStat('.');
1028
+ * console.log(`This directory is owned by ${stats.uid}`);
1029
+ * }
1030
+ *
1031
+ * callStat();
1032
+ * ```
1033
+ *
1034
+ * 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).
1036
+ *
1037
+ * `promisify()` assumes that `original` is a function taking a callback as its
1038
+ * final argument in all cases. If `original` is not a function, `promisify()`
1039
+ * will throw an error. If `original` is a function but its last argument is not
1040
+ * an error-first callback, it will still be passed an error-first
1041
+ * callback as its last argument.
1042
+ *
1043
+ * Using `promisify()` on class methods or other methods that use `this` may not
1044
+ * work as expected unless handled specially:
1045
+ *
1046
+ * ```js
1047
+ * import { promisify } from 'node:util';
1048
+ *
1049
+ * class Foo {
1050
+ * constructor() {
1051
+ * this.a = 42;
1052
+ * }
1053
+ *
1054
+ * bar(callback) {
1055
+ * callback(null, this.a);
1056
+ * }
1057
+ * }
1058
+ *
1059
+ * const foo = new Foo();
1060
+ *
1061
+ * const naiveBar = promisify(foo.bar);
1062
+ * // TypeError: Cannot read properties of undefined (reading 'a')
1063
+ * // naiveBar().then(a => console.log(a));
1064
+ *
1065
+ * naiveBar.call(foo).then((a) => console.log(a)); // '42'
1066
+ *
1067
+ * const bindBar = naiveBar.bind(foo);
1068
+ * bindBar().then((a) => console.log(a)); // '42'
1069
+ * ```
1070
+ * @since v8.0.0
1071
+ */
1072
+ export function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
1073
+ export function promisify<TResult>(
1074
+ fn: (callback: (err: any, result: TResult) => void) => void,
1075
+ ): () => Promise<TResult>;
1076
+ export function promisify(fn: (callback: (err?: any) => void) => void): () => Promise<void>;
1077
+ export function promisify<T1, TResult>(
1078
+ fn: (arg1: T1, callback: (err: any, result: TResult) => void) => void,
1079
+ ): (arg1: T1) => Promise<TResult>;
1080
+ export function promisify<T1>(fn: (arg1: T1, callback: (err?: any) => void) => void): (arg1: T1) => Promise<void>;
1081
+ export function promisify<T1, T2, TResult>(
1082
+ fn: (arg1: T1, arg2: T2, callback: (err: any, result: TResult) => void) => void,
1083
+ ): (arg1: T1, arg2: T2) => Promise<TResult>;
1084
+ export function promisify<T1, T2>(
1085
+ fn: (arg1: T1, arg2: T2, callback: (err?: any) => void) => void,
1086
+ ): (arg1: T1, arg2: T2) => Promise<void>;
1087
+ export function promisify<T1, T2, T3, TResult>(
1088
+ fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: TResult) => void) => void,
1089
+ ): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
1090
+ export function promisify<T1, T2, T3>(
1091
+ fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err?: any) => void) => void,
1092
+ ): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
1093
+ export function promisify<T1, T2, T3, T4, TResult>(
1094
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => void) => void,
1095
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
1096
+ export function promisify<T1, T2, T3, T4>(
1097
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err?: any) => void) => void,
1098
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
1099
+ export function promisify<T1, T2, T3, T4, T5, TResult>(
1100
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => void) => void,
1101
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
1102
+ export function promisify<T1, T2, T3, T4, T5>(
1103
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err?: any) => void) => void,
1104
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
1105
+ export function promisify(fn: Function): Function;
1106
+ export namespace promisify {
1107
+ /**
1108
+ * That can be used to declare custom promisified variants of functions.
1109
+ */
1110
+ const custom: unique symbol;
1111
+ }
1112
+ /**
1113
+ * Stability: 1.1 - Active development
1114
+ * Given an example `.env` file:
1115
+ *
1116
+ * ```js
1117
+ * import { parseEnv } from 'node:util';
1118
+ *
1119
+ * parseEnv('HELLO=world\nHELLO=oh my\n');
1120
+ * // Returns: { HELLO: 'oh my' }
1121
+ * ```
1122
+ * @param content The raw contents of a `.env` file.
1123
+ * @since v20.12.0
1124
+ */
1125
+ 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
+ export interface StyleTextOptions {
1181
+ /**
1182
+ * When true, `stream` is checked to see if it can handle colors.
1183
+ * @default true
1184
+ */
1185
+ validateStream?: boolean | undefined;
1186
+ /**
1187
+ * A stream that will be validated if it can be colored.
1188
+ * @default process.stdout
1189
+ */
1190
+ stream?: NodeJS.WritableStream | undefined;
1191
+ }
1192
+ /**
1193
+ * This function returns a formatted text considering the `format` passed
1194
+ * for printing in a terminal. It is aware of the terminal's capabilities
1195
+ * and acts according to the configuration set via `NO_COLOR`,
1196
+ * `NODE_DISABLE_COLORS` and `FORCE_COLOR` environment variables.
1197
+ *
1198
+ * ```js
1199
+ * import { styleText } from 'node:util';
1200
+ * import { stderr } from 'node:process';
1201
+ *
1202
+ * const successMessage = styleText('green', 'Success!');
1203
+ * console.log(successMessage);
1204
+ *
1205
+ * const errorMessage = styleText(
1206
+ * 'red',
1207
+ * 'Error! Error!',
1208
+ * // Validate if process.stderr has TTY
1209
+ * { stream: stderr },
1210
+ * );
1211
+ * console.error(errorMessage);
1212
+ * ```
1213
+ *
1214
+ * `util.inspect.colors` also provides text formats such as `italic`, and
1215
+ * `underline` and you can combine both:
1216
+ *
1217
+ * ```js
1218
+ * console.log(
1219
+ * util.styleText(['underline', 'italic'], 'My italic underlined message'),
1220
+ * );
1221
+ * ```
1222
+ *
1223
+ * When passing an array of formats, the order of the format applied
1224
+ * is left to right so the following style might overwrite the previous one.
1225
+ *
1226
+ * ```js
1227
+ * console.log(
1228
+ * util.styleText(['red', 'green'], 'text'), // green
1229
+ * );
1230
+ * ```
1231
+ *
1232
+ * The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v24.x/api/util.html#modifiers).
1233
+ * @param format A text format or an Array of text formats defined in `util.inspect.colors`.
1234
+ * @param text The text to to be formatted.
1235
+ * @since v20.12.0
1236
+ */
1237
+ export function styleText(
1238
+ format:
1239
+ | ForegroundColors
1240
+ | BackgroundColors
1241
+ | Modifiers
1242
+ | Array<ForegroundColors | BackgroundColors | Modifiers>,
1243
+ text: string,
1244
+ options?: StyleTextOptions,
1245
+ ): 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
+
1368
+ //// parseArgs
1369
+ /**
1370
+ * Provides a higher level API for command-line argument parsing than interacting
1371
+ * with `process.argv` directly. Takes a specification for the expected arguments
1372
+ * and returns a structured object with the parsed options and positionals.
1373
+ *
1374
+ * ```js
1375
+ * import { parseArgs } from 'node:util';
1376
+ * const args = ['-f', '--bar', 'b'];
1377
+ * const options = {
1378
+ * foo: {
1379
+ * type: 'boolean',
1380
+ * short: 'f',
1381
+ * },
1382
+ * bar: {
1383
+ * type: 'string',
1384
+ * },
1385
+ * };
1386
+ * const {
1387
+ * values,
1388
+ * positionals,
1389
+ * } = parseArgs({ args, options });
1390
+ * console.log(values, positionals);
1391
+ * // Prints: [Object: null prototype] { foo: true, bar: 'b' } []
1392
+ * ```
1393
+ * @since v18.3.0, v16.17.0
1394
+ * @param config Used to provide arguments for parsing and to configure the parser. `config` supports the following properties:
1395
+ * @return The parsed command line arguments:
1396
+ */
1397
+ export function parseArgs<T extends ParseArgsConfig>(config?: T): ParsedResults<T>;
1398
+
1399
+ /**
1400
+ * Type of argument used in {@link parseArgs}.
1401
+ */
1402
+ export type ParseArgsOptionsType = "boolean" | "string";
1403
+
1404
+ export interface ParseArgsOptionDescriptor {
1405
+ /**
1406
+ * Type of argument.
1407
+ */
1408
+ type: ParseArgsOptionsType;
1409
+ /**
1410
+ * Whether this option can be provided multiple times.
1411
+ * If `true`, all values will be collected in an array.
1412
+ * If `false`, values for the option are last-wins.
1413
+ * @default false.
1414
+ */
1415
+ multiple?: boolean | undefined;
1416
+ /**
1417
+ * A single character alias for the option.
1418
+ */
1419
+ short?: string | undefined;
1420
+ /**
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.
1425
+ * @since v18.11.0
1426
+ */
1427
+ default?: string | boolean | string[] | boolean[] | undefined;
1428
+ }
1429
+ export interface ParseArgsOptionsConfig {
1430
+ [longOption: string]: ParseArgsOptionDescriptor;
1431
+ }
1432
+ export interface ParseArgsConfig {
1433
+ /**
1434
+ * Array of argument strings.
1435
+ */
1436
+ args?: string[] | undefined;
1437
+ /**
1438
+ * Used to describe arguments known to the parser.
1439
+ */
1440
+ options?: ParseArgsOptionsConfig | undefined;
1441
+ /**
1442
+ * Should an error be thrown when unknown arguments are encountered,
1443
+ * or when arguments are passed that do not match the `type` configured in `options`.
1444
+ * @default true
1445
+ */
1446
+ strict?: boolean | undefined;
1447
+ /**
1448
+ * Whether this command accepts positional arguments.
1449
+ */
1450
+ allowPositionals?: boolean | undefined;
1451
+ /**
1452
+ * If `true`, allows explicitly setting boolean options to `false` by prefixing the option name with `--no-`.
1453
+ * @default false
1454
+ * @since v22.4.0
1455
+ */
1456
+ allowNegative?: boolean | undefined;
1457
+ /**
1458
+ * Return the parsed tokens. This is useful for extending the built-in behavior,
1459
+ * from adding additional checks through to reprocessing the tokens in different ways.
1460
+ * @default false
1461
+ */
1462
+ tokens?: boolean | undefined;
1463
+ }
1464
+ /*
1465
+ IfDefaultsTrue and IfDefaultsFalse are helpers to handle default values for missing boolean properties.
1466
+ TypeScript does not have exact types for objects: https://github.com/microsoft/TypeScript/issues/12936
1467
+ This means it is impossible to distinguish between "field X is definitely not present" and "field X may or may not be present".
1468
+ But we expect users to generally provide their config inline or `as const`, which means TS will always know whether a given field is present.
1469
+ So this helper treats "not definitely present" (i.e., not `extends boolean`) as being "definitely not present", i.e. it should have its default value.
1470
+ This is technically incorrect but is a much nicer UX for the common case.
1471
+ The IfDefaultsTrue version is for things which default to true; the IfDefaultsFalse version is for things which default to false.
1472
+ */
1473
+ type IfDefaultsTrue<T, IfTrue, IfFalse> = T extends true ? IfTrue
1474
+ : T extends false ? IfFalse
1475
+ : IfTrue;
1476
+
1477
+ // we put the `extends false` condition first here because `undefined` compares like `any` when `strictNullChecks: false`
1478
+ type IfDefaultsFalse<T, IfTrue, IfFalse> = T extends false ? IfFalse
1479
+ : T extends true ? IfTrue
1480
+ : IfFalse;
1481
+
1482
+ type ExtractOptionValue<T extends ParseArgsConfig, O extends ParseArgsOptionDescriptor> = IfDefaultsTrue<
1483
+ T["strict"],
1484
+ O["type"] extends "string" ? string : O["type"] extends "boolean" ? boolean : string | boolean,
1485
+ string | boolean
1486
+ >;
1487
+
1488
+ type ApplyOptionalModifiers<O extends ParseArgsOptionsConfig, V extends Record<keyof O, unknown>> = (
1489
+ & { -readonly [LongOption in keyof O]?: V[LongOption] }
1490
+ & { [LongOption in keyof O as O[LongOption]["default"] extends {} ? LongOption : never]: V[LongOption] }
1491
+ ) extends infer P ? { [K in keyof P]: P[K] } : never; // resolve intersection to object
1492
+
1493
+ type ParsedValues<T extends ParseArgsConfig> =
1494
+ & IfDefaultsTrue<T["strict"], unknown, { [longOption: string]: undefined | string | boolean }>
1495
+ & (T["options"] extends ParseArgsOptionsConfig ? ApplyOptionalModifiers<
1496
+ T["options"],
1497
+ {
1498
+ [LongOption in keyof T["options"]]: IfDefaultsFalse<
1499
+ T["options"][LongOption]["multiple"],
1500
+ Array<ExtractOptionValue<T, T["options"][LongOption]>>,
1501
+ ExtractOptionValue<T, T["options"][LongOption]>
1502
+ >;
1503
+ }
1504
+ >
1505
+ : {});
1506
+
1507
+ type ParsedPositionals<T extends ParseArgsConfig> = IfDefaultsTrue<
1508
+ T["strict"],
1509
+ IfDefaultsFalse<T["allowPositionals"], string[], []>,
1510
+ IfDefaultsTrue<T["allowPositionals"], string[], []>
1511
+ >;
1512
+
1513
+ type PreciseTokenForOptions<
1514
+ K extends string,
1515
+ O extends ParseArgsOptionDescriptor,
1516
+ > = O["type"] extends "string" ? {
1517
+ kind: "option";
1518
+ index: number;
1519
+ name: K;
1520
+ rawName: string;
1521
+ value: string;
1522
+ inlineValue: boolean;
1523
+ }
1524
+ : O["type"] extends "boolean" ? {
1525
+ kind: "option";
1526
+ index: number;
1527
+ name: K;
1528
+ rawName: string;
1529
+ value: undefined;
1530
+ inlineValue: undefined;
1531
+ }
1532
+ : OptionToken & { name: K };
1533
+
1534
+ type TokenForOptions<
1535
+ T extends ParseArgsConfig,
1536
+ K extends keyof T["options"] = keyof T["options"],
1537
+ > = K extends unknown
1538
+ ? T["options"] extends ParseArgsOptionsConfig ? PreciseTokenForOptions<K & string, T["options"][K]>
1539
+ : OptionToken
1540
+ : never;
1541
+
1542
+ type ParsedOptionToken<T extends ParseArgsConfig> = IfDefaultsTrue<T["strict"], TokenForOptions<T>, OptionToken>;
1543
+
1544
+ type ParsedPositionalToken<T extends ParseArgsConfig> = IfDefaultsTrue<
1545
+ T["strict"],
1546
+ IfDefaultsFalse<T["allowPositionals"], { kind: "positional"; index: number; value: string }, never>,
1547
+ IfDefaultsTrue<T["allowPositionals"], { kind: "positional"; index: number; value: string }, never>
1548
+ >;
1549
+
1550
+ type ParsedTokens<T extends ParseArgsConfig> = Array<
1551
+ ParsedOptionToken<T> | ParsedPositionalToken<T> | { kind: "option-terminator"; index: number }
1552
+ >;
1553
+
1554
+ type PreciseParsedResults<T extends ParseArgsConfig> = IfDefaultsFalse<
1555
+ T["tokens"],
1556
+ {
1557
+ values: ParsedValues<T>;
1558
+ positionals: ParsedPositionals<T>;
1559
+ tokens: ParsedTokens<T>;
1560
+ },
1561
+ {
1562
+ values: ParsedValues<T>;
1563
+ positionals: ParsedPositionals<T>;
1564
+ }
1565
+ >;
1566
+
1567
+ type OptionToken =
1568
+ | { kind: "option"; index: number; name: string; rawName: string; value: string; inlineValue: boolean }
1569
+ | {
1570
+ kind: "option";
1571
+ index: number;
1572
+ name: string;
1573
+ rawName: string;
1574
+ value: undefined;
1575
+ inlineValue: undefined;
1576
+ };
1577
+
1578
+ type Token =
1579
+ | OptionToken
1580
+ | { kind: "positional"; index: number; value: string }
1581
+ | { kind: "option-terminator"; index: number };
1582
+
1583
+ // If ParseArgsConfig extends T, then the user passed config constructed elsewhere.
1584
+ // So we can't rely on the `"not definitely present" implies "definitely not present"` assumption mentioned above.
1585
+ type ParsedResults<T extends ParseArgsConfig> = ParseArgsConfig extends T ? {
1586
+ values: {
1587
+ [longOption: string]: undefined | string | boolean | Array<string | boolean>;
1588
+ };
1589
+ positionals: string[];
1590
+ tokens?: Token[];
1591
+ }
1592
+ : PreciseParsedResults<T>;
1593
+
1594
+ /**
1595
+ * An implementation of [the MIMEType class](https://bmeck.github.io/node-proposal-mime-api/).
1596
+ *
1597
+ * In accordance with browser conventions, all properties of `MIMEType` objects
1598
+ * are implemented as getters and setters on the class prototype, rather than as
1599
+ * data properties on the object itself.
1600
+ *
1601
+ * A MIME string is a structured string containing multiple meaningful
1602
+ * components. When parsed, a `MIMEType` object is returned containing
1603
+ * properties for each of these components.
1604
+ * @since v19.1.0, v18.13.0
1605
+ */
1606
+ export class MIMEType {
1607
+ /**
1608
+ * Creates a new MIMEType object by parsing the input.
1609
+ *
1610
+ * A `TypeError` will be thrown if the `input` is not a valid MIME.
1611
+ * Note that an effort will be made to coerce the given values into strings.
1612
+ * @param input The input MIME to parse.
1613
+ */
1614
+ constructor(input: string | { toString: () => string });
1615
+
1616
+ /**
1617
+ * Gets and sets the type portion of the MIME.
1618
+ *
1619
+ * ```js
1620
+ * import { MIMEType } from 'node:util';
1621
+ *
1622
+ * const myMIME = new MIMEType('text/javascript');
1623
+ * console.log(myMIME.type);
1624
+ * // Prints: text
1625
+ * myMIME.type = 'application';
1626
+ * console.log(myMIME.type);
1627
+ * // Prints: application
1628
+ * console.log(String(myMIME));
1629
+ * // Prints: application/javascript
1630
+ * ```
1631
+ */
1632
+ type: string;
1633
+ /**
1634
+ * Gets and sets the subtype portion of the MIME.
1635
+ *
1636
+ * ```js
1637
+ * import { MIMEType } from 'node:util';
1638
+ *
1639
+ * const myMIME = new MIMEType('text/ecmascript');
1640
+ * console.log(myMIME.subtype);
1641
+ * // Prints: ecmascript
1642
+ * myMIME.subtype = 'javascript';
1643
+ * console.log(myMIME.subtype);
1644
+ * // Prints: javascript
1645
+ * console.log(String(myMIME));
1646
+ * // Prints: text/javascript
1647
+ * ```
1648
+ */
1649
+ subtype: string;
1650
+ /**
1651
+ * Gets the essence of the MIME. This property is read only.
1652
+ * Use `mime.type` or `mime.subtype` to alter the MIME.
1653
+ *
1654
+ * ```js
1655
+ * import { MIMEType } from 'node:util';
1656
+ *
1657
+ * const myMIME = new MIMEType('text/javascript;key=value');
1658
+ * console.log(myMIME.essence);
1659
+ * // Prints: text/javascript
1660
+ * myMIME.type = 'application';
1661
+ * console.log(myMIME.essence);
1662
+ * // Prints: application/javascript
1663
+ * console.log(String(myMIME));
1664
+ * // Prints: application/javascript;key=value
1665
+ * ```
1666
+ */
1667
+ readonly essence: string;
1668
+ /**
1669
+ * Gets the `MIMEParams` object representing the
1670
+ * parameters of the MIME. This property is read-only. See `MIMEParams` documentation for details.
1671
+ */
1672
+ readonly params: MIMEParams;
1673
+ /**
1674
+ * The `toString()` method on the `MIMEType` object returns the serialized MIME.
1675
+ *
1676
+ * Because of the need for standard compliance, this method does not allow users
1677
+ * to customize the serialization process of the MIME.
1678
+ */
1679
+ toString(): string;
1680
+ }
1681
+ /**
1682
+ * The `MIMEParams` API provides read and write access to the parameters of a `MIMEType`.
1683
+ * @since v19.1.0, v18.13.0
1684
+ */
1685
+ export class MIMEParams {
1686
+ /**
1687
+ * Remove all name-value pairs whose name is `name`.
1688
+ */
1689
+ delete(name: string): void;
1690
+ /**
1691
+ * Returns an iterator over each of the name-value pairs in the parameters.
1692
+ * Each item of the iterator is a JavaScript `Array`. The first item of the array
1693
+ * is the `name`, the second item of the array is the `value`.
1694
+ */
1695
+ entries(): NodeJS.Iterator<[name: string, value: string]>;
1696
+ /**
1697
+ * Returns the value of the first name-value pair whose name is `name`. If there
1698
+ * are no such pairs, `null` is returned.
1699
+ * @return or `null` if there is no name-value pair with the given `name`.
1700
+ */
1701
+ get(name: string): string | null;
1702
+ /**
1703
+ * Returns `true` if there is at least one name-value pair whose name is `name`.
1704
+ */
1705
+ has(name: string): boolean;
1706
+ /**
1707
+ * Returns an iterator over the names of each name-value pair.
1708
+ *
1709
+ * ```js
1710
+ * import { MIMEType } from 'node:util';
1711
+ *
1712
+ * const { params } = new MIMEType('text/plain;foo=0;bar=1');
1713
+ * for (const name of params.keys()) {
1714
+ * console.log(name);
1715
+ * }
1716
+ * // Prints:
1717
+ * // foo
1718
+ * // bar
1719
+ * ```
1720
+ */
1721
+ keys(): NodeJS.Iterator<string>;
1722
+ /**
1723
+ * Sets the value in the `MIMEParams` object associated with `name` to `value`. If there are any pre-existing name-value pairs whose names are `name`,
1724
+ * set the first such pair's value to `value`.
1725
+ *
1726
+ * ```js
1727
+ * import { MIMEType } from 'node:util';
1728
+ *
1729
+ * const { params } = new MIMEType('text/plain;foo=0;bar=1');
1730
+ * params.set('foo', 'def');
1731
+ * params.set('baz', 'xyz');
1732
+ * console.log(params.toString());
1733
+ * // Prints: foo=def;bar=1;baz=xyz
1734
+ * ```
1735
+ */
1736
+ set(name: string, value: string): void;
1737
+ /**
1738
+ * Returns an iterator over the values of each name-value pair.
1739
+ */
1740
+ values(): NodeJS.Iterator<string>;
1741
+ /**
1742
+ * Returns an iterator over each of the name-value pairs in the parameters.
1743
+ */
1744
+ [Symbol.iterator](): NodeJS.Iterator<[name: string, value: string]>;
1745
+ }
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;
2300
+ }