@types/node 20.19.25 → 24.10.3

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 (79) hide show
  1. {node v20.19 → node v24.10}/README.md +3 -3
  2. node v24.10/assert/strict.d.ts +111 -0
  3. {node v20.19 → node v24.10}/assert.d.ts +150 -97
  4. {node v20.19 → node v24.10}/async_hooks.d.ts +27 -9
  5. {node v20.19 → node v24.10}/buffer.buffer.d.ts +2 -1
  6. {node v20.19 → node v24.10}/buffer.d.ts +6 -8
  7. {node v20.19 → node v24.10}/child_process.d.ts +11 -10
  8. {node v20.19 → node v24.10}/cluster.d.ts +16 -15
  9. {node v20.19 → node v24.10}/console.d.ts +19 -18
  10. {node v20.19 → node v24.10}/crypto.d.ts +1120 -293
  11. {node v20.19 → node v24.10}/dgram.d.ts +5 -2
  12. {node v20.19 → node v24.10}/diagnostics_channel.d.ts +1 -3
  13. {node v20.19 → node v24.10}/dns/promises.d.ts +30 -6
  14. {node v20.19 → node v24.10}/dns.d.ts +69 -17
  15. {node v20.19 → node v24.10}/domain.d.ts +1 -1
  16. {node v20.19 → node v24.10}/events.d.ts +1 -2
  17. {node v20.19 → node v24.10}/fs/promises.d.ts +85 -38
  18. {node v20.19 → node v24.10}/fs.d.ts +387 -48
  19. {node v20.19 → node v24.10}/globals.d.ts +2 -4
  20. {node v20.19 → node v24.10}/globals.typedarray.d.ts +3 -0
  21. {node v20.19 → node v24.10}/http.d.ts +90 -5
  22. {node v20.19 → node v24.10}/http2.d.ts +166 -41
  23. {node v20.19 → node v24.10}/https.d.ts +4 -3
  24. {node v20.19 → node v24.10}/index.d.ts +13 -5
  25. node v24.10/inspector.d.ts +277 -0
  26. {node v20.19 → node v24.10}/inspector.generated.d.ts +1096 -829
  27. {node v20.19 → node v24.10}/module.d.ts +403 -48
  28. {node v20.19 → node v24.10}/net.d.ts +62 -20
  29. {node v20.19 → node v24.10}/os.d.ts +8 -7
  30. {node v20.19 → node v24.10}/package.json +18 -3
  31. {node v20.19 → node v24.10}/path.d.ts +3 -3
  32. {node v20.19 → node v24.10}/perf_hooks.d.ts +37 -16
  33. {node v20.19 → node v24.10}/process.d.ts +133 -16
  34. {node v20.19 → node v24.10}/punycode.d.ts +1 -1
  35. {node v20.19 → node v24.10}/querystring.d.ts +1 -1
  36. {node v20.19 → node v24.10}/readline/promises.d.ts +0 -1
  37. {node v20.19 → node v24.10}/readline.d.ts +19 -14
  38. {node v20.19 → node v24.10}/repl.d.ts +25 -17
  39. {node v20.19 → node v24.10}/sea.d.ts +11 -2
  40. node v24.10/sqlite.d.ts +937 -0
  41. {node v20.19 → node v24.10}/stream/web.d.ts +85 -45
  42. {node v20.19 → node v24.10}/stream.d.ts +36 -28
  43. {node v20.19 → node v24.10}/string_decoder.d.ts +1 -1
  44. {node v20.19 → node v24.10}/test.d.ts +587 -35
  45. {node v20.19 → node v24.10}/timers/promises.d.ts +1 -1
  46. {node v20.19 → node v24.10}/timers.d.ts +4 -5
  47. {node v20.19 → node v24.10}/tls.d.ts +62 -48
  48. {node v20.19 → node v24.10}/trace_events.d.ts +6 -6
  49. node v24.10/ts5.6/compatibility/float16array.d.ts +71 -0
  50. {node v20.19 → node v24.10}/ts5.6/globals.typedarray.d.ts +2 -0
  51. {node v20.19 → node v24.10}/ts5.6/index.d.ts +15 -5
  52. node v24.10/ts5.7/compatibility/float16array.d.ts +72 -0
  53. node v24.10/ts5.7/index.d.ts +103 -0
  54. {node v20.19 → node v24.10}/tty.d.ts +1 -1
  55. {node v20.19 → node v24.10}/url.d.ts +128 -35
  56. {node v20.19 → node v24.10}/util.d.ts +384 -390
  57. {node v20.19 → node v24.10}/v8.d.ts +175 -32
  58. {node v20.19 → node v24.10}/vm.d.ts +246 -67
  59. {node v20.19 → node v24.10}/wasi.d.ts +23 -2
  60. node v24.10/web-globals/crypto.d.ts +32 -0
  61. {node v20.19 → node v24.10}/web-globals/fetch.d.ts +4 -0
  62. node v24.10/web-globals/navigator.d.ts +25 -0
  63. node v24.10/web-globals/storage.d.ts +24 -0
  64. node v24.10/web-globals/streams.d.ts +22 -0
  65. {node v20.19 → node v24.10}/worker_threads.d.ts +205 -24
  66. {node v20.19 → node v24.10}/zlib.d.ts +185 -44
  67. node v20.19/assert/strict.d.ts +0 -8
  68. node v20.19/compatibility/disposable.d.ts +0 -16
  69. node v20.19/compatibility/index.d.ts +0 -9
  70. node v20.19/compatibility/indexable.d.ts +0 -20
  71. {node v20.19 → node v24.10}/LICENSE +0 -0
  72. {node v20.19 → node v24.10}/compatibility/iterators.d.ts +0 -0
  73. {node v20.19 → node v24.10}/constants.d.ts +0 -0
  74. {node v20.19 → node v24.10}/stream/consumers.d.ts +0 -0
  75. {node v20.19 → node v24.10}/stream/promises.d.ts +0 -0
  76. {node v20.19 → node v24.10}/ts5.6/buffer.buffer.d.ts +0 -0
  77. {node v20.19 → node v24.10}/web-globals/abortcontroller.d.ts +0 -0
  78. {node v20.19 → node v24.10}/web-globals/domexception.d.ts +0 -0
  79. {node v20.19 → node v24.10}/web-globals/events.d.ts +0 -0
@@ -6,7 +6,7 @@
6
6
  * ```js
7
7
  * import util from 'node:util';
8
8
  * ```
9
- * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/util.js)
9
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/util.js)
10
10
  */
11
11
  declare module "util" {
12
12
  import * as types from "node:util/types";
@@ -108,6 +108,83 @@ declare module "util" {
108
108
  export interface InspectOptionsStylized extends InspectOptions {
109
109
  stylize(text: string, styleType: Style): string;
110
110
  }
111
+ export interface CallSiteObject {
112
+ /**
113
+ * Returns the name of the function associated with this call site.
114
+ */
115
+ functionName: string;
116
+ /**
117
+ * Returns the name of the resource that contains the script for the
118
+ * function for this call site.
119
+ */
120
+ scriptName: string;
121
+ /**
122
+ * Returns the unique id of the script, as in Chrome DevTools protocol
123
+ * [`Runtime.ScriptId`](https://chromedevtools.github.io/devtools-protocol/1-3/Runtime/#type-ScriptId).
124
+ * @since v22.14.0
125
+ */
126
+ scriptId: string;
127
+ /**
128
+ * Returns the number, 1-based, of the line for the associate function call.
129
+ */
130
+ lineNumber: number;
131
+ /**
132
+ * Returns the 1-based column offset on the line for the associated function call.
133
+ */
134
+ columnNumber: number;
135
+ }
136
+ export type DiffEntry = [operation: -1 | 0 | 1, value: string];
137
+ /**
138
+ * `util.diff()` compares two string or array values and returns an array of difference entries.
139
+ * It uses the Myers diff algorithm to compute minimal differences, which is the same algorithm
140
+ * used internally by assertion error messages.
141
+ *
142
+ * If the values are equal, an empty array is returned.
143
+ *
144
+ * ```js
145
+ * const { diff } = require('node:util');
146
+ *
147
+ * // Comparing strings
148
+ * const actualString = '12345678';
149
+ * const expectedString = '12!!5!7!';
150
+ * console.log(diff(actualString, expectedString));
151
+ * // [
152
+ * // [0, '1'],
153
+ * // [0, '2'],
154
+ * // [1, '3'],
155
+ * // [1, '4'],
156
+ * // [-1, '!'],
157
+ * // [-1, '!'],
158
+ * // [0, '5'],
159
+ * // [1, '6'],
160
+ * // [-1, '!'],
161
+ * // [0, '7'],
162
+ * // [1, '8'],
163
+ * // [-1, '!'],
164
+ * // ]
165
+ * // Comparing arrays
166
+ * const actualArray = ['1', '2', '3'];
167
+ * const expectedArray = ['1', '3', '4'];
168
+ * console.log(diff(actualArray, expectedArray));
169
+ * // [
170
+ * // [0, '1'],
171
+ * // [1, '2'],
172
+ * // [0, '3'],
173
+ * // [-1, '4'],
174
+ * // ]
175
+ * // Equal values return empty array
176
+ * console.log(diff('same', 'same'));
177
+ * // []
178
+ * ```
179
+ * @since v22.15.0
180
+ * @experimental
181
+ * @param actual The first value to compare
182
+ * @param expected The second value to compare
183
+ * @returns An array of difference entries. Each entry is an array with two elements:
184
+ * * Index 0: `number` Operation code: `-1` for delete, `0` for no-op/unchanged, `1` for insert
185
+ * * Index 1: `string` The value associated with the operation
186
+ */
187
+ export function diff(actual: string | readonly string[], expected: string | readonly string[]): DiffEntry[];
111
188
  /**
112
189
  * The `util.format()` method returns a formatted string using the first argument
113
190
  * as a `printf`-like format string which can contain zero or more format
@@ -166,6 +243,87 @@ declare module "util" {
166
243
  * @since v10.0.0
167
244
  */
168
245
  export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string;
246
+ interface GetCallSitesOptions {
247
+ /**
248
+ * Reconstruct the original location in the stacktrace from the source-map.
249
+ * Enabled by default with the flag `--enable-source-maps`.
250
+ */
251
+ sourceMap?: boolean | undefined;
252
+ }
253
+ /**
254
+ * Returns an array of call site objects containing the stack of
255
+ * the caller function.
256
+ *
257
+ * ```js
258
+ * import { getCallSites } from 'node:util';
259
+ *
260
+ * function exampleFunction() {
261
+ * const callSites = getCallSites();
262
+ *
263
+ * console.log('Call Sites:');
264
+ * callSites.forEach((callSite, index) => {
265
+ * console.log(`CallSite ${index + 1}:`);
266
+ * console.log(`Function Name: ${callSite.functionName}`);
267
+ * console.log(`Script Name: ${callSite.scriptName}`);
268
+ * console.log(`Line Number: ${callSite.lineNumber}`);
269
+ * console.log(`Column Number: ${callSite.column}`);
270
+ * });
271
+ * // CallSite 1:
272
+ * // Function Name: exampleFunction
273
+ * // Script Name: /home/example.js
274
+ * // Line Number: 5
275
+ * // Column Number: 26
276
+ *
277
+ * // CallSite 2:
278
+ * // Function Name: anotherFunction
279
+ * // Script Name: /home/example.js
280
+ * // Line Number: 22
281
+ * // Column Number: 3
282
+ *
283
+ * // ...
284
+ * }
285
+ *
286
+ * // A function to simulate another stack layer
287
+ * function anotherFunction() {
288
+ * exampleFunction();
289
+ * }
290
+ *
291
+ * anotherFunction();
292
+ * ```
293
+ *
294
+ * It is possible to reconstruct the original locations by setting the option `sourceMap` to `true`.
295
+ * If the source map is not available, the original location will be the same as the current location.
296
+ * When the `--enable-source-maps` flag is enabled, for example when using `--experimental-transform-types`,
297
+ * `sourceMap` will be true by default.
298
+ *
299
+ * ```ts
300
+ * import { getCallSites } from 'node:util';
301
+ *
302
+ * interface Foo {
303
+ * foo: string;
304
+ * }
305
+ *
306
+ * const callSites = getCallSites({ sourceMap: true });
307
+ *
308
+ * // With sourceMap:
309
+ * // Function Name: ''
310
+ * // Script Name: example.js
311
+ * // Line Number: 7
312
+ * // Column Number: 26
313
+ *
314
+ * // Without sourceMap:
315
+ * // Function Name: ''
316
+ * // Script Name: example.js
317
+ * // Line Number: 2
318
+ * // Column Number: 26
319
+ * ```
320
+ * @param frameCount Number of frames to capture as call site objects.
321
+ * **Default:** `10`. Allowable range is between 1 and 200.
322
+ * @return An array of call site objects
323
+ * @since v22.9.0
324
+ */
325
+ export function getCallSites(frameCount?: number, options?: GetCallSitesOptions): CallSiteObject[];
326
+ export function getCallSites(options: GetCallSitesOptions): CallSiteObject[];
169
327
  /**
170
328
  * Returns the string name for a numeric error code that comes from a Node.js API.
171
329
  * The mapping between error codes and error names is platform-dependent.
@@ -180,6 +338,11 @@ declare module "util" {
180
338
  * @since v9.7.0
181
339
  */
182
340
  export function getSystemErrorName(err: number): string;
341
+ /**
342
+ * Enable or disable printing a stack trace on `SIGINT`. The API is only available on the main thread.
343
+ * @since 24.6.0
344
+ */
345
+ export function setTraceSigInt(enable: boolean): void;
183
346
  /**
184
347
  * Returns a Map of all system error codes available from the Node.js API.
185
348
  * The mapping between error codes and error names is platform-dependent.
@@ -196,18 +359,19 @@ declare module "util" {
196
359
  */
197
360
  export function getSystemErrorMap(): Map<number, [string, string]>;
198
361
  /**
199
- * The `util.log()` method prints the given `string` to `stdout` with an included
200
- * timestamp.
362
+ * Returns the string message for a numeric error code that comes from a Node.js
363
+ * API.
364
+ * The mapping between error codes and string messages is platform-dependent.
201
365
  *
202
366
  * ```js
203
- * import util from 'node:util';
204
- *
205
- * util.log('Timestamped message.');
367
+ * fs.access('file/that/does/not/exist', (err) => {
368
+ * const message = util.getSystemErrorMessage(err.errno);
369
+ * console.error(message); // no such file or directory
370
+ * });
206
371
  * ```
207
- * @since v0.3.0
208
- * @deprecated Since v6.0.0 - Use a third party module instead.
372
+ * @since v22.12.0
209
373
  */
210
- export function log(string: string): void;
374
+ export function getSystemErrorMessage(err: number): string;
211
375
  /**
212
376
  * Returns the `string` after replacing any surrogate code points
213
377
  * (or equivalently, any unpaired surrogate code units) with the
@@ -219,7 +383,6 @@ declare module "util" {
219
383
  * Creates and returns an `AbortController` instance whose `AbortSignal` is marked
220
384
  * as transferable and can be used with `structuredClone()` or `postMessage()`.
221
385
  * @since v18.11.0
222
- * @experimental
223
386
  * @returns A transferable AbortController
224
387
  */
225
388
  export function transferableAbortController(): AbortController;
@@ -232,41 +395,49 @@ declare module "util" {
232
395
  * channel.port2.postMessage(signal, [signal]);
233
396
  * ```
234
397
  * @since v18.11.0
235
- * @experimental
236
398
  * @param signal The AbortSignal
237
399
  * @returns The same AbortSignal
238
400
  */
239
401
  export function transferableAbortSignal(signal: AbortSignal): AbortSignal;
240
402
  /**
241
- * Listens to abort event on the provided `signal` and
242
- * returns a promise that is fulfilled when the `signal` is
243
- * aborted. If the passed `resource` is garbage collected before the `signal` is
244
- * aborted, the returned promise shall remain pending indefinitely.
403
+ * Listens to abort event on the provided `signal` and returns a promise that resolves when the `signal` is aborted.
404
+ * If `resource` is provided, it weakly references the operation's associated object,
405
+ * so if `resource` is garbage collected before the `signal` aborts,
406
+ * then returned promise shall remain pending.
407
+ * This prevents memory leaks in long-running or non-cancelable operations.
245
408
  *
246
409
  * ```js
247
410
  * import { aborted } from 'node:util';
248
411
  *
412
+ * // Obtain an object with an abortable signal, like a custom resource or operation.
249
413
  * const dependent = obtainSomethingAbortable();
250
414
  *
415
+ * // Pass `dependent` as the resource, indicating the promise should only resolve
416
+ * // if `dependent` is still in memory when the signal is aborted.
251
417
  * aborted(dependent.signal, dependent).then(() => {
252
- * // Do something when dependent is aborted.
418
+ * // This code runs when `dependent` is aborted.
419
+ * console.log('Dependent resource was aborted.');
253
420
  * });
254
421
  *
422
+ * // Simulate an event that triggers the abort.
255
423
  * dependent.on('event', () => {
256
- * dependent.abort();
424
+ * dependent.abort(); // This will cause the `aborted` promise to resolve.
257
425
  * });
258
426
  * ```
259
427
  * @since v19.7.0
260
- * @experimental
261
- * @param resource Any non-null entity, reference to which is held weakly.
428
+ * @param resource Any non-null object tied to the abortable operation and held weakly.
429
+ * If `resource` is garbage collected before the `signal` aborts, the promise remains pending,
430
+ * allowing Node.js to stop tracking it.
431
+ * This helps prevent memory leaks in long-running or non-cancelable operations.
262
432
  */
263
433
  export function aborted(signal: AbortSignal, resource: any): Promise<void>;
264
434
  /**
265
435
  * The `util.inspect()` method returns a string representation of `object` that is
266
436
  * intended for debugging. The output of `util.inspect` may change at any time
267
437
  * and should not be depended upon programmatically. Additional `options` may be
268
- * passed that alter the result. `util.inspect()` will use the constructor's name and/or `@@toStringTag` to make
269
- * an identifiable tag for an inspected value.
438
+ * passed that alter the result.
439
+ * `util.inspect()` will use the constructor's name and/or `Symbol.toStringTag`
440
+ * property to make an identifiable tag for an inspected value.
270
441
  *
271
442
  * ```js
272
443
  * class Foo {
@@ -313,7 +484,7 @@ declare module "util" {
313
484
  * The following example highlights the effect of the `compact` option:
314
485
  *
315
486
  * ```js
316
- * import util from 'node:util';
487
+ * import { inspect } from 'node:util';
317
488
  *
318
489
  * const o = {
319
490
  * a: [1, 2, [[
@@ -323,7 +494,7 @@ declare module "util" {
323
494
  * 'foo']], 4],
324
495
  * b: new Map([['za', 1], ['zb', 'test']]),
325
496
  * };
326
- * console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 }));
497
+ * console.log(inspect(o, { compact: true, depth: 5, breakLength: 80 }));
327
498
  *
328
499
  * // { a:
329
500
  * // [ 1,
@@ -335,7 +506,7 @@ declare module "util" {
335
506
  * // b: Map(2) { 'za' => 1, 'zb' => 'test' } }
336
507
  *
337
508
  * // Setting `compact` to false or an integer creates more reader friendly output.
338
- * console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));
509
+ * console.log(inspect(o, { compact: false, depth: 5, breakLength: 80 }));
339
510
  *
340
511
  * // {
341
512
  * // a: [
@@ -362,11 +533,10 @@ declare module "util" {
362
533
  * // single line.
363
534
  * ```
364
535
  *
365
- * The `showHidden` option allows [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) and
366
- * [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) entries to be
536
+ * The `showHidden` option allows `WeakMap` and `WeakSet` entries to be
367
537
  * inspected. If there are more entries than `maxArrayLength`, there is no
368
- * guarantee which entries are displayed. That means retrieving the same [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) entries twice may
369
- * result in different output. Furthermore, entries
538
+ * guarantee which entries are displayed. That means retrieving the same
539
+ * `WeakSet` entries twice may result in different output. Furthermore, entries
370
540
  * with no remaining strong references may be garbage collected at any time.
371
541
  *
372
542
  * ```js
@@ -414,10 +584,10 @@ declare module "util" {
414
584
  * ```js
415
585
  * import { inspect } from 'node:util';
416
586
  *
417
- * const thousand = 1_000;
418
- * const million = 1_000_000;
419
- * const bigNumber = 123_456_789n;
420
- * const bigDecimal = 1_234.123_45;
587
+ * const thousand = 1000;
588
+ * const million = 1000000;
589
+ * const bigNumber = 123456789n;
590
+ * const bigDecimal = 1234.12345;
421
591
  *
422
592
  * console.log(inspect(thousand, { numericSeparator: true }));
423
593
  * // 1_000
@@ -473,84 +643,23 @@ declare module "util" {
473
643
  */
474
644
  export function isArray(object: unknown): object is unknown[];
475
645
  /**
476
- * Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`.
477
- *
478
- * ```js
479
- * import util from 'node:util';
480
- *
481
- * util.isRegExp(/some regexp/);
482
- * // Returns: true
483
- * util.isRegExp(new RegExp('another regexp'));
484
- * // Returns: true
485
- * util.isRegExp({});
486
- * // Returns: false
487
- * ```
488
- * @since v0.6.0
489
- * @deprecated Since v4.0.0 - Deprecated
490
- */
491
- export function isRegExp(object: unknown): object is RegExp;
492
- /**
493
- * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
494
- *
495
- * ```js
496
- * import util from 'node:util';
497
- *
498
- * util.isDate(new Date());
499
- * // Returns: true
500
- * util.isDate(Date());
501
- * // false (without 'new' returns a String)
502
- * util.isDate({});
503
- * // Returns: false
504
- * ```
505
- * @since v0.6.0
506
- * @deprecated Since v4.0.0 - Use {@link types.isDate} instead.
507
- */
508
- export function isDate(object: unknown): object is Date;
509
- /**
510
- * Returns `true` if the given `object` is an `Error`. Otherwise, returns `false`.
511
- *
512
- * ```js
513
- * import util from 'node:util';
514
- *
515
- * util.isError(new Error());
516
- * // Returns: true
517
- * util.isError(new TypeError());
518
- * // Returns: true
519
- * util.isError({ name: 'Error', message: 'an error occurred' });
520
- * // Returns: false
521
- * ```
522
- *
523
- * This method relies on `Object.prototype.toString()` behavior. It is
524
- * possible to obtain an incorrect result when the `object` argument manipulates `@@toStringTag`.
525
- *
526
- * ```js
527
- * import util from 'node:util';
528
- * const obj = { name: 'Error', message: 'an error occurred' };
529
- *
530
- * util.isError(obj);
531
- * // Returns: false
532
- * obj[Symbol.toStringTag] = 'Error';
533
- * util.isError(obj);
534
- * // Returns: true
535
- * ```
536
- * @since v0.6.0
537
- * @deprecated Since v4.0.0 - Use {@link types.isNativeError} instead.
538
- */
539
- export function isError(object: unknown): object is Error;
540
- /**
541
- * Usage of `util.inherits()` is discouraged. Please use the ES6 `class` and `extends` keywords to get language level inheritance support. Also note
646
+ * Usage of `util.inherits()` is discouraged. Please use the ES6 `class` and
647
+ * `extends` keywords to get language level inheritance support. Also note
542
648
  * that the two styles are [semantically incompatible](https://github.com/nodejs/node/issues/4179).
543
649
  *
544
- * Inherit the prototype methods from one [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor) into another. The
545
- * prototype of `constructor` will be set to a new object created from `superConstructor`.
650
+ * Inherit the prototype methods from one
651
+ * [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor) into another. The
652
+ * prototype of `constructor` will be set to a new object created from
653
+ * `superConstructor`.
546
654
  *
547
- * This mainly adds some input validation on top of`Object.setPrototypeOf(constructor.prototype, superConstructor.prototype)`.
655
+ * This mainly adds some input validation on top of
656
+ * `Object.setPrototypeOf(constructor.prototype, superConstructor.prototype)`.
548
657
  * As an additional convenience, `superConstructor` will be accessible
549
658
  * through the `constructor.super_` property.
550
659
  *
551
660
  * ```js
552
- * import util from 'node:util';
553
- * import EventEmitter from 'node:events';
661
+ * const util = require('node:util');
662
+ * const EventEmitter = require('node:events');
554
663
  *
555
664
  * function MyStream() {
556
665
  * EventEmitter.call(this);
@@ -597,18 +706,42 @@ declare module "util" {
597
706
  export function inherits(constructor: unknown, superConstructor: unknown): void;
598
707
  export type DebugLoggerFunction = (msg: string, ...param: unknown[]) => void;
599
708
  export interface DebugLogger extends DebugLoggerFunction {
709
+ /**
710
+ * The `util.debuglog().enabled` getter is used to create a test that can be used
711
+ * in conditionals based on the existence of the `NODE_DEBUG` environment variable.
712
+ * If the `section` name appears within the value of that environment variable,
713
+ * then the returned value will be `true`. If not, then the returned value will be
714
+ * `false`.
715
+ *
716
+ * ```js
717
+ * import { debuglog } from 'node:util';
718
+ * const enabled = debuglog('foo').enabled;
719
+ * if (enabled) {
720
+ * console.log('hello from foo [%d]', 123);
721
+ * }
722
+ * ```
723
+ *
724
+ * If this program is run with `NODE_DEBUG=foo` in the environment, then it will
725
+ * output something like:
726
+ *
727
+ * ```console
728
+ * hello from foo [123]
729
+ * ```
730
+ */
600
731
  enabled: boolean;
601
732
  }
602
733
  /**
603
734
  * The `util.debuglog()` method is used to create a function that conditionally
604
- * writes debug messages to `stderr` based on the existence of the `NODE_DEBUG`environment variable. If the `section` name appears within the value of that
605
- * environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op.
735
+ * writes debug messages to `stderr` based on the existence of the `NODE_DEBUG`
736
+ * environment variable. If the `section` name appears within the value of that
737
+ * environment variable, then the returned function operates similar to
738
+ * `console.error()`. If not, then the returned function is a no-op.
606
739
  *
607
740
  * ```js
608
- * import util from 'node:util';
609
- * const debuglog = util.debuglog('foo');
741
+ * import { debuglog } from 'node:util';
742
+ * const log = debuglog('foo');
610
743
  *
611
- * debuglog('hello from foo [%d]', 123);
744
+ * log('hello from foo [%d]', 123);
612
745
  * ```
613
746
  *
614
747
  * If this program is run with `NODE_DEBUG=foo` in the environment, then
@@ -624,10 +757,10 @@ declare module "util" {
624
757
  * The `section` supports wildcard also:
625
758
  *
626
759
  * ```js
627
- * import util from 'node:util';
628
- * const debuglog = util.debuglog('foo-bar');
760
+ * import { debuglog } from 'node:util';
761
+ * const log = debuglog('foo');
629
762
  *
630
- * debuglog('hi there, it\'s foo-bar [%d]', 2333);
763
+ * log('hi there, it\'s foo-bar [%d]', 2333);
631
764
  * ```
632
765
  *
633
766
  * if it is run with `NODE_DEBUG=foo*` in the environment, then it will output
@@ -637,18 +770,19 @@ declare module "util" {
637
770
  * FOO-BAR 3257: hi there, it's foo-bar [2333]
638
771
  * ```
639
772
  *
640
- * Multiple comma-separated `section` names may be specified in the `NODE_DEBUG`environment variable: `NODE_DEBUG=fs,net,tls`.
773
+ * Multiple comma-separated `section` names may be specified in the `NODE_DEBUG`
774
+ * environment variable: `NODE_DEBUG=fs,net,tls`.
641
775
  *
642
776
  * The optional `callback` argument can be used to replace the logging function
643
777
  * with a different function that doesn't have any initialization or
644
778
  * unnecessary wrapping.
645
779
  *
646
780
  * ```js
647
- * import util from 'node:util';
648
- * let debuglog = util.debuglog('internals', (debug) => {
781
+ * import { debuglog } from 'node:util';
782
+ * let log = debuglog('internals', (debug) => {
649
783
  * // Replace with a logging function that optimizes out
650
784
  * // testing if the section is enabled
651
- * debuglog = debug;
785
+ * log = debug;
652
786
  * });
653
787
  * ```
654
788
  * @since v0.11.3
@@ -657,231 +791,21 @@ declare module "util" {
657
791
  * @return The logging function
658
792
  */
659
793
  export function debuglog(section: string, callback?: (fn: DebugLoggerFunction) => void): DebugLogger;
660
- export const debug: typeof debuglog;
661
- /**
662
- * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
663
- *
664
- * ```js
665
- * import util from 'node:util';
666
- *
667
- * util.isBoolean(1);
668
- * // Returns: false
669
- * util.isBoolean(0);
670
- * // Returns: false
671
- * util.isBoolean(false);
672
- * // Returns: true
673
- * ```
674
- * @since v0.11.5
675
- * @deprecated Since v4.0.0 - Use `typeof value === 'boolean'` instead.
676
- */
677
- export function isBoolean(object: unknown): object is boolean;
678
- /**
679
- * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`.
680
- *
681
- * ```js
682
- * import util from 'node:util';
683
- *
684
- * util.isBuffer({ length: 0 });
685
- * // Returns: false
686
- * util.isBuffer([]);
687
- * // Returns: false
688
- * util.isBuffer(Buffer.from('hello world'));
689
- * // Returns: true
690
- * ```
691
- * @since v0.11.5
692
- * @deprecated Since v4.0.0 - Use `isBuffer` instead.
693
- */
694
- export function isBuffer(object: unknown): object is Buffer;
695
- /**
696
- * Returns `true` if the given `object` is a `Function`. Otherwise, returns `false`.
697
- *
698
- * ```js
699
- * import util from 'node:util';
700
- *
701
- * function Foo() {}
702
- * const Bar = () => {};
703
- *
704
- * util.isFunction({});
705
- * // Returns: false
706
- * util.isFunction(Foo);
707
- * // Returns: true
708
- * util.isFunction(Bar);
709
- * // Returns: true
710
- * ```
711
- * @since v0.11.5
712
- * @deprecated Since v4.0.0 - Use `typeof value === 'function'` instead.
713
- */
714
- export function isFunction(object: unknown): boolean;
715
- /**
716
- * Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`.
717
- *
718
- * ```js
719
- * import util from 'node:util';
720
- *
721
- * util.isNull(0);
722
- * // Returns: false
723
- * util.isNull(undefined);
724
- * // Returns: false
725
- * util.isNull(null);
726
- * // Returns: true
727
- * ```
728
- * @since v0.11.5
729
- * @deprecated Since v4.0.0 - Use `value === null` instead.
730
- */
731
- export function isNull(object: unknown): object is null;
732
- /**
733
- * Returns `true` if the given `object` is `null` or `undefined`. Otherwise,
734
- * returns `false`.
735
- *
736
- * ```js
737
- * import util from 'node:util';
738
- *
739
- * util.isNullOrUndefined(0);
740
- * // Returns: false
741
- * util.isNullOrUndefined(undefined);
742
- * // Returns: true
743
- * util.isNullOrUndefined(null);
744
- * // Returns: true
745
- * ```
746
- * @since v0.11.5
747
- * @deprecated Since v4.0.0 - Use `value === undefined || value === null` instead.
748
- */
749
- export function isNullOrUndefined(object: unknown): object is null | undefined;
750
- /**
751
- * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.
752
- *
753
- * ```js
754
- * import util from 'node:util';
755
- *
756
- * util.isNumber(false);
757
- * // Returns: false
758
- * util.isNumber(Infinity);
759
- * // Returns: true
760
- * util.isNumber(0);
761
- * // Returns: true
762
- * util.isNumber(NaN);
763
- * // Returns: true
764
- * ```
765
- * @since v0.11.5
766
- * @deprecated Since v4.0.0 - Use `typeof value === 'number'` instead.
767
- */
768
- export function isNumber(object: unknown): object is number;
769
- /**
770
- * Returns `true` if the given `object` is strictly an `Object`**and** not a`Function` (even though functions are objects in JavaScript).
771
- * Otherwise, returns `false`.
772
- *
773
- * ```js
774
- * import util from 'node:util';
775
- *
776
- * util.isObject(5);
777
- * // Returns: false
778
- * util.isObject(null);
779
- * // Returns: false
780
- * util.isObject({});
781
- * // Returns: true
782
- * util.isObject(() => {});
783
- * // Returns: false
784
- * ```
785
- * @since v0.11.5
786
- * @deprecated Since v4.0.0 - Use `value !== null && typeof value === 'object'` instead.
787
- */
788
- export function isObject(object: unknown): boolean;
789
- /**
790
- * Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`.
791
- *
792
- * ```js
793
- * import util from 'node:util';
794
- *
795
- * util.isPrimitive(5);
796
- * // Returns: true
797
- * util.isPrimitive('foo');
798
- * // Returns: true
799
- * util.isPrimitive(false);
800
- * // Returns: true
801
- * util.isPrimitive(null);
802
- * // Returns: true
803
- * util.isPrimitive(undefined);
804
- * // Returns: true
805
- * util.isPrimitive({});
806
- * // Returns: false
807
- * util.isPrimitive(() => {});
808
- * // Returns: false
809
- * util.isPrimitive(/^$/);
810
- * // Returns: false
811
- * util.isPrimitive(new Date());
812
- * // Returns: false
813
- * ```
814
- * @since v0.11.5
815
- * @deprecated Since v4.0.0 - Use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead.
816
- */
817
- export function isPrimitive(object: unknown): boolean;
818
- /**
819
- * Returns `true` if the given `object` is a `string`. Otherwise, returns `false`.
820
- *
821
- * ```js
822
- * import util from 'node:util';
823
- *
824
- * util.isString('');
825
- * // Returns: true
826
- * util.isString('foo');
827
- * // Returns: true
828
- * util.isString(String('foo'));
829
- * // Returns: true
830
- * util.isString(5);
831
- * // Returns: false
832
- * ```
833
- * @since v0.11.5
834
- * @deprecated Since v4.0.0 - Use `typeof value === 'string'` instead.
835
- */
836
- export function isString(object: unknown): object is string;
837
- /**
838
- * Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`.
839
- *
840
- * ```js
841
- * import util from 'node:util';
842
- *
843
- * util.isSymbol(5);
844
- * // Returns: false
845
- * util.isSymbol('foo');
846
- * // Returns: false
847
- * util.isSymbol(Symbol('foo'));
848
- * // Returns: true
849
- * ```
850
- * @since v0.11.5
851
- * @deprecated Since v4.0.0 - Use `typeof value === 'symbol'` instead.
852
- */
853
- export function isSymbol(object: unknown): object is symbol;
854
- /**
855
- * Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`.
856
- *
857
- * ```js
858
- * import util from 'node:util';
859
- *
860
- * const foo = undefined;
861
- * util.isUndefined(5);
862
- * // Returns: false
863
- * util.isUndefined(foo);
864
- * // Returns: true
865
- * util.isUndefined(null);
866
- * // Returns: false
867
- * ```
868
- * @since v0.11.5
869
- * @deprecated Since v4.0.0 - Use `value === undefined` instead.
870
- */
871
- export function isUndefined(object: unknown): object is undefined;
794
+ export { debuglog as debug };
872
795
  /**
873
796
  * The `util.deprecate()` method wraps `fn` (which may be a function or class) in
874
797
  * such a way that it is marked as deprecated.
875
798
  *
876
799
  * ```js
877
- * import util from 'node:util';
800
+ * import { deprecate } from 'node:util';
878
801
  *
879
- * exports.obsoleteFunction = util.deprecate(() => {
802
+ * export const obsoleteFunction = deprecate(() => {
880
803
  * // Do something here.
881
804
  * }, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.');
882
805
  * ```
883
806
  *
884
- * When called, `util.deprecate()` will return a function that will emit a `DeprecationWarning` using the `'warning'` event. The warning will
807
+ * When called, `util.deprecate()` will return a function that will emit a
808
+ * `DeprecationWarning` using the `'warning'` event. The warning will
885
809
  * be emitted and printed to `stderr` the first time the returned function is
886
810
  * called. After the warning is emitted, the wrapped function is called without
887
811
  * emitting a warning.
@@ -890,16 +814,24 @@ declare module "util" {
890
814
  * the warning will be emitted only once for that `code`.
891
815
  *
892
816
  * ```js
893
- * import util from 'node:util';
817
+ * import { deprecate } from 'node:util';
894
818
  *
895
- * const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001');
896
- * const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001');
819
+ * const fn1 = deprecate(
820
+ * () => 'a value',
821
+ * 'deprecation message',
822
+ * 'DEP0001',
823
+ * );
824
+ * const fn2 = deprecate(
825
+ * () => 'a different value',
826
+ * 'other dep message',
827
+ * 'DEP0001',
828
+ * );
897
829
  * fn1(); // Emits a deprecation warning with code DEP0001
898
830
  * fn2(); // Does not emit a deprecation warning because it has the same code
899
831
  * ```
900
832
  *
901
833
  * If either the `--no-deprecation` or `--no-warnings` command-line flags are
902
- * used, or if the `process.noDeprecation` property is set to `true`_prior_ to
834
+ * used, or if the `process.noDeprecation` property is set to `true` _prior_ to
903
835
  * the first deprecation warning, the `util.deprecate()` method does nothing.
904
836
  *
905
837
  * If the `--trace-deprecation` or `--trace-warnings` command-line flags are set,
@@ -907,10 +839,13 @@ declare module "util" {
907
839
  * stack trace are printed to `stderr` the first time the deprecated function is
908
840
  * called.
909
841
  *
910
- * If the `--throw-deprecation` command-line flag is set, or the `process.throwDeprecation` property is set to `true`, then an exception will be
842
+ * If the `--throw-deprecation` command-line flag is set, or the
843
+ * `process.throwDeprecation` property is set to `true`, then an exception will be
911
844
  * thrown when the deprecated function is called.
912
845
  *
913
- * The `--throw-deprecation` command-line flag and `process.throwDeprecation` property take precedence over `--trace-deprecation` and `process.traceDeprecation`.
846
+ * The `--throw-deprecation` command-line flag and `process.throwDeprecation`
847
+ * property take precedence over `--trace-deprecation` and
848
+ * `process.traceDeprecation`.
914
849
  * @since v0.8.0
915
850
  * @param fn The function that is being deprecated.
916
851
  * @param msg A warning message to display when the deprecated function is invoked.
@@ -918,6 +853,15 @@ declare module "util" {
918
853
  * @return The deprecated function wrapped to emit a warning.
919
854
  */
920
855
  export function deprecate<T extends Function>(fn: T, msg: string, code?: string): T;
856
+ export interface IsDeepStrictEqualOptions {
857
+ /**
858
+ * If `true`, prototype and constructor
859
+ * comparison is skipped during deep strict equality check.
860
+ * @since v24.9.0
861
+ * @default false
862
+ */
863
+ skipPrototype?: boolean | undefined;
864
+ }
921
865
  /**
922
866
  * Returns `true` if there is deep strict equality between `val1` and `val2`.
923
867
  * Otherwise, returns `false`.
@@ -926,7 +870,7 @@ declare module "util" {
926
870
  * equality.
927
871
  * @since v9.0.0
928
872
  */
929
- export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean;
873
+ export function isDeepStrictEqual(val1: unknown, val2: unknown, options?: IsDeepStrictEqualOptions): boolean;
930
874
  /**
931
875
  * Returns `str` with any ANSI escape codes removed.
932
876
  *
@@ -941,15 +885,16 @@ declare module "util" {
941
885
  * Takes an `async` function (or a function that returns a `Promise`) and returns a
942
886
  * function following the error-first callback style, i.e. taking
943
887
  * an `(err, value) => ...` callback as the last argument. In the callback, the
944
- * first argument will be the rejection reason (or `null` if the `Promise` resolved), and the second argument will be the resolved value.
888
+ * first argument will be the rejection reason (or `null` if the `Promise`
889
+ * resolved), and the second argument will be the resolved value.
945
890
  *
946
891
  * ```js
947
- * import util from 'node:util';
892
+ * import { callbackify } from 'node:util';
948
893
  *
949
894
  * async function fn() {
950
895
  * return 'hello world';
951
896
  * }
952
- * const callbackFunction = util.callbackify(fn);
897
+ * const callbackFunction = callbackify(fn);
953
898
  *
954
899
  * callbackFunction((err, ret) => {
955
900
  * if (err) throw err;
@@ -964,11 +909,13 @@ declare module "util" {
964
909
  * ```
965
910
  *
966
911
  * The callback is executed asynchronously, and will have a limited stack trace.
967
- * If the callback throws, the process will emit an `'uncaughtException'` event, and if not handled will exit.
912
+ * If the callback throws, the process will emit an `'uncaughtException'`
913
+ * event, and if not handled will exit.
968
914
  *
969
915
  * Since `null` has a special meaning as the first argument to a callback, if a
970
916
  * wrapped function rejects a `Promise` with a falsy value as a reason, the value
971
- * is wrapped in an `Error` with the original value stored in a field named `reason`.
917
+ * is wrapped in an `Error` with the original value stored in a field named
918
+ * `reason`.
972
919
  *
973
920
  * ```js
974
921
  * function fn() {
@@ -979,7 +926,7 @@ declare module "util" {
979
926
  * callbackFunction((err, ret) => {
980
927
  * // When the Promise was rejected with `null` it is wrapped with an Error and
981
928
  * // the original value is stored in `reason`.
982
- * err &#x26;&#x26; Object.hasOwn(err, 'reason') &#x26;&#x26; err.reason === null; // true
929
+ * err && Object.hasOwn(err, 'reason') && err.reason === null; // true
983
930
  * });
984
931
  * ```
985
932
  * @since v8.2.0
@@ -1070,11 +1017,11 @@ declare module "util" {
1070
1017
  * that returns promises.
1071
1018
  *
1072
1019
  * ```js
1073
- * import util from 'node:util';
1074
- * import fs from 'node:fs';
1020
+ * import { promisify } from 'node:util';
1021
+ * import { stat } from 'node:fs';
1075
1022
  *
1076
- * const stat = util.promisify(fs.stat);
1077
- * stat('.').then((stats) => {
1023
+ * const promisifiedStat = promisify(stat);
1024
+ * promisifiedStat('.').then((stats) => {
1078
1025
  * // Do something with `stats`
1079
1026
  * }).catch((error) => {
1080
1027
  * // Handle the error.
@@ -1084,23 +1031,25 @@ declare module "util" {
1084
1031
  * Or, equivalently using `async function`s:
1085
1032
  *
1086
1033
  * ```js
1087
- * import util from 'node:util';
1088
- * import fs from 'node:fs';
1034
+ * import { promisify } from 'node:util';
1035
+ * import { stat } from 'node:fs';
1089
1036
  *
1090
- * const stat = util.promisify(fs.stat);
1037
+ * const promisifiedStat = promisify(stat);
1091
1038
  *
1092
1039
  * async function callStat() {
1093
- * const stats = await stat('.');
1040
+ * const stats = await promisifiedStat('.');
1094
1041
  * console.log(`This directory is owned by ${stats.uid}`);
1095
1042
  * }
1096
1043
  *
1097
1044
  * callStat();
1098
1045
  * ```
1099
1046
  *
1100
- * If there is an `original[util.promisify.custom]` property present, `promisify` will return its value, see `Custom promisified functions`.
1047
+ * If there is an `original[util.promisify.custom]` property present, `promisify`
1048
+ * will return its value, see [Custom promisified functions](https://nodejs.org/docs/latest-v24.x/api/util.html#custom-promisified-functions).
1101
1049
  *
1102
1050
  * `promisify()` assumes that `original` is a function taking a callback as its
1103
- * final argument in all cases. If `original` is not a function, `promisify()` will throw an error. If `original` is a function but its last argument is not
1051
+ * final argument in all cases. If `original` is not a function, `promisify()`
1052
+ * will throw an error. If `original` is a function but its last argument is not
1104
1053
  * an error-first callback, it will still be passed an error-first
1105
1054
  * callback as its last argument.
1106
1055
  *
@@ -1108,7 +1057,7 @@ declare module "util" {
1108
1057
  * work as expected unless handled specially:
1109
1058
  *
1110
1059
  * ```js
1111
- * import util from 'node:util';
1060
+ * import { promisify } from 'node:util';
1112
1061
  *
1113
1062
  * class Foo {
1114
1063
  * constructor() {
@@ -1122,8 +1071,8 @@ declare module "util" {
1122
1071
  *
1123
1072
  * const foo = new Foo();
1124
1073
  *
1125
- * const naiveBar = util.promisify(foo.bar);
1126
- * // TypeError: Cannot read property 'a' of undefined
1074
+ * const naiveBar = promisify(foo.bar);
1075
+ * // TypeError: Cannot read properties of undefined (reading 'a')
1127
1076
  * // naiveBar().then(a => console.log(a));
1128
1077
  *
1129
1078
  * naiveBar.call(foo).then((a) => console.log(a)); // '42'
@@ -1237,6 +1186,7 @@ declare module "util" {
1237
1186
  | "hidden"
1238
1187
  | "inverse"
1239
1188
  | "italic"
1189
+ | "none"
1240
1190
  | "overlined"
1241
1191
  | "reset"
1242
1192
  | "strikethrough"
@@ -1254,17 +1204,29 @@ declare module "util" {
1254
1204
  stream?: NodeJS.WritableStream | undefined;
1255
1205
  }
1256
1206
  /**
1257
- * Stability: 1.1 - Active development
1258
- *
1259
- * This function returns a formatted text considering the `format` passed.
1207
+ * This function returns a formatted text considering the `format` passed
1208
+ * for printing in a terminal. It is aware of the terminal's capabilities
1209
+ * and acts according to the configuration set via `NO_COLOR`,
1210
+ * `NODE_DISABLE_COLORS` and `FORCE_COLOR` environment variables.
1260
1211
  *
1261
1212
  * ```js
1262
1213
  * import { styleText } from 'node:util';
1263
- * const errorMessage = styleText('red', 'Error! Error!');
1264
- * console.log(errorMessage);
1214
+ * import { stderr } from 'node:process';
1215
+ *
1216
+ * const successMessage = styleText('green', 'Success!');
1217
+ * console.log(successMessage);
1218
+ *
1219
+ * const errorMessage = styleText(
1220
+ * 'red',
1221
+ * 'Error! Error!',
1222
+ * // Validate if process.stderr has TTY
1223
+ * { stream: stderr },
1224
+ * );
1225
+ * console.error(errorMessage);
1265
1226
  * ```
1266
1227
  *
1267
- * `util.inspect.colors` also provides text formats such as `italic`, and `underline` and you can combine both:
1228
+ * `util.inspect.colors` also provides text formats such as `italic`, and
1229
+ * `underline` and you can combine both:
1268
1230
  *
1269
1231
  * ```js
1270
1232
  * console.log(
@@ -1272,8 +1234,8 @@ declare module "util" {
1272
1234
  * );
1273
1235
  * ```
1274
1236
  *
1275
- * When passing an array of formats, the order of the format applied is left to right so the following style
1276
- * might overwrite the previous one.
1237
+ * When passing an array of formats, the order of the format applied
1238
+ * is left to right so the following style might overwrite the previous one.
1277
1239
  *
1278
1240
  * ```js
1279
1241
  * console.log(
@@ -1281,7 +1243,9 @@ declare module "util" {
1281
1243
  * );
1282
1244
  * ```
1283
1245
  *
1284
- * The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v20.x/api/util.html#modifiers).
1246
+ * The special format value `none` applies no additional styling to the text.
1247
+ *
1248
+ * The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v24.x/api/util.html#modifiers).
1285
1249
  * @param format A text format or an Array of text formats defined in `util.inspect.colors`.
1286
1250
  * @param text The text to to be formatted.
1287
1251
  * @since v20.12.0
@@ -1447,11 +1411,17 @@ declare module "util" {
1447
1411
  * @return The parsed command line arguments:
1448
1412
  */
1449
1413
  export function parseArgs<T extends ParseArgsConfig>(config?: T): ParsedResults<T>;
1450
- interface ParseArgsOptionConfig {
1414
+
1415
+ /**
1416
+ * Type of argument used in {@link parseArgs}.
1417
+ */
1418
+ export type ParseArgsOptionsType = "boolean" | "string";
1419
+
1420
+ export interface ParseArgsOptionDescriptor {
1451
1421
  /**
1452
1422
  * Type of argument.
1453
1423
  */
1454
- type: "string" | "boolean";
1424
+ type: ParseArgsOptionsType;
1455
1425
  /**
1456
1426
  * Whether this option can be provided multiple times.
1457
1427
  * If `true`, all values will be collected in an array.
@@ -1464,15 +1434,18 @@ declare module "util" {
1464
1434
  */
1465
1435
  short?: string | undefined;
1466
1436
  /**
1467
- * The default option value when it is not set by args.
1468
- * It must be of the same type as the the `type` property.
1469
- * When `multiple` is `true`, it must be an array.
1437
+ * The value to assign to
1438
+ * the option if it does not appear in the arguments to be parsed. The value
1439
+ * must match the type specified by the `type` property. If `multiple` is
1440
+ * `true`, it must be an array. No default value is applied when the option
1441
+ * does appear in the arguments to be parsed, even if the provided value
1442
+ * is falsy.
1470
1443
  * @since v18.11.0
1471
1444
  */
1472
1445
  default?: string | boolean | string[] | boolean[] | undefined;
1473
1446
  }
1474
- interface ParseArgsOptionsConfig {
1475
- [longOption: string]: ParseArgsOptionConfig;
1447
+ export interface ParseArgsOptionsConfig {
1448
+ [longOption: string]: ParseArgsOptionDescriptor;
1476
1449
  }
1477
1450
  export interface ParseArgsConfig {
1478
1451
  /**
@@ -1496,7 +1469,7 @@ declare module "util" {
1496
1469
  /**
1497
1470
  * If `true`, allows explicitly setting boolean options to `false` by prefixing the option name with `--no-`.
1498
1471
  * @default false
1499
- * @since v20.16.0
1472
+ * @since v22.4.0
1500
1473
  */
1501
1474
  allowNegative?: boolean | undefined;
1502
1475
  /**
@@ -1524,7 +1497,7 @@ declare module "util" {
1524
1497
  : T extends true ? IfTrue
1525
1498
  : IfFalse;
1526
1499
 
1527
- type ExtractOptionValue<T extends ParseArgsConfig, O extends ParseArgsOptionConfig> = IfDefaultsTrue<
1500
+ type ExtractOptionValue<T extends ParseArgsConfig, O extends ParseArgsOptionDescriptor> = IfDefaultsTrue<
1528
1501
  T["strict"],
1529
1502
  O["type"] extends "string" ? string : O["type"] extends "boolean" ? boolean : string | boolean,
1530
1503
  string | boolean
@@ -1557,7 +1530,7 @@ declare module "util" {
1557
1530
 
1558
1531
  type PreciseTokenForOptions<
1559
1532
  K extends string,
1560
- O extends ParseArgsOptionConfig,
1533
+ O extends ParseArgsOptionDescriptor,
1561
1534
  > = O["type"] extends "string" ? {
1562
1535
  kind: "option";
1563
1536
  index: number;
@@ -1647,7 +1620,6 @@ declare module "util" {
1647
1620
  * components. When parsed, a `MIMEType` object is returned containing
1648
1621
  * properties for each of these components.
1649
1622
  * @since v19.1.0, v18.13.0
1650
- * @experimental
1651
1623
  */
1652
1624
  export class MIMEType {
1653
1625
  /**
@@ -1946,7 +1918,9 @@ declare module "util/types" {
1946
1918
  * A native `External` value is a special type of object that contains a
1947
1919
  * raw C++ pointer (`void*`) for access from native code, and has no other
1948
1920
  * properties. Such objects are created either by Node.js internals or native
1949
- * addons. In JavaScript, they are [frozen](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) objects with a`null` prototype.
1921
+ * addons. In JavaScript, they are
1922
+ * [frozen](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) objects with a
1923
+ * `null` prototype.
1950
1924
  *
1951
1925
  * ```c
1952
1926
  * #include <js_native_api.h>
@@ -1954,7 +1928,7 @@ declare module "util/types" {
1954
1928
  * napi_value result;
1955
1929
  * static napi_value MyNapi(napi_env env, napi_callback_info info) {
1956
1930
  * int* raw = (int*) malloc(1024);
1957
- * napi_status status = napi_create_external(env, (void*) raw, NULL, NULL, &#x26;result);
1931
+ * napi_status status = napi_create_external(env, (void*) raw, NULL, NULL, &result);
1958
1932
  * if (status != napi_ok) {
1959
1933
  * napi_throw_error(env, NULL, "napi_create_external failed");
1960
1934
  * return NULL;
@@ -1967,17 +1941,31 @@ declare module "util/types" {
1967
1941
  * ```
1968
1942
  *
1969
1943
  * ```js
1970
- * const native =require('napi_addon.node');
1944
+ * import native from 'napi_addon.node';
1945
+ * import { types } from 'node:util';
1946
+ *
1971
1947
  * const data = native.myNapi();
1972
- * util.types.isExternal(data); // returns true
1973
- * util.types.isExternal(0); // returns false
1974
- * util.types.isExternal(new String('foo')); // returns false
1948
+ * types.isExternal(data); // returns true
1949
+ * types.isExternal(0); // returns false
1950
+ * types.isExternal(new String('foo')); // returns false
1975
1951
  * ```
1976
1952
  *
1977
- * For further information on `napi_create_external`, refer to `napi_create_external()`.
1953
+ * For further information on `napi_create_external`, refer to
1954
+ * [`napi_create_external()`](https://nodejs.org/docs/latest-v24.x/api/n-api.html#napi_create_external).
1978
1955
  * @since v10.0.0
1979
1956
  */
1980
1957
  function isExternal(object: unknown): boolean;
1958
+ /**
1959
+ * Returns `true` if the value is a built-in [`Float16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array) instance.
1960
+ *
1961
+ * ```js
1962
+ * util.types.isFloat16Array(new ArrayBuffer()); // Returns false
1963
+ * util.types.isFloat16Array(new Float16Array()); // Returns true
1964
+ * util.types.isFloat16Array(new Float32Array()); // Returns false
1965
+ * ```
1966
+ * @since v24.0.0
1967
+ */
1968
+ function isFloat16Array(object: unknown): object is Float16Array;
1981
1969
  /**
1982
1970
  * Returns `true` if the value is a built-in [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array) instance.
1983
1971
  *
@@ -2098,7 +2086,8 @@ declare module "util/types" {
2098
2086
  */
2099
2087
  function isModuleNamespaceObject(value: unknown): boolean;
2100
2088
  /**
2101
- * Returns `true` if the value was returned by the constructor of a [built-in `Error` type](https://tc39.es/ecma262/#sec-error-objects).
2089
+ * Returns `true` if the value was returned by the constructor of a
2090
+ * [built-in `Error` type](https://tc39.es/ecma262/#sec-error-objects).
2102
2091
  *
2103
2092
  * ```js
2104
2093
  * console.log(util.types.isNativeError(new Error())); // true
@@ -2113,14 +2102,18 @@ declare module "util/types" {
2113
2102
  * console.log(util.types.isNativeError(new MyError())); // true
2114
2103
  * ```
2115
2104
  *
2116
- * A value being `instanceof` a native error class is not equivalent to `isNativeError()` returning `true` for that value. `isNativeError()` returns `true` for errors
2117
- * which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false` for these errors:
2105
+ * A value being `instanceof` a native error class is not equivalent to `isNativeError()`
2106
+ * returning `true` for that value. `isNativeError()` returns `true` for errors
2107
+ * which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false`
2108
+ * for these errors:
2118
2109
  *
2119
2110
  * ```js
2120
- * import vm from 'node:vm';
2121
- * const context = vm.createContext({});
2122
- * const myError = vm.runInContext('new Error()', context);
2123
- * console.log(util.types.isNativeError(myError)); // true
2111
+ * import { createContext, runInContext } from 'node:vm';
2112
+ * import { types } from 'node:util';
2113
+ *
2114
+ * const context = createContext({});
2115
+ * const myError = runInContext('new Error()', context);
2116
+ * console.log(types.isNativeError(myError)); // true
2124
2117
  * console.log(myError instanceof Error); // false
2125
2118
  * ```
2126
2119
  *
@@ -2134,6 +2127,7 @@ declare module "util/types" {
2134
2127
  * console.log(myError instanceof Error); // true
2135
2128
  * ```
2136
2129
  * @since v10.0.0
2130
+ * @deprecated The `util.types.isNativeError` API is deprecated. Please use `Error.isError` instead.
2137
2131
  */
2138
2132
  function isNativeError(object: unknown): object is Error;
2139
2133
  /**