@types/node 26.0.0 → 26.1.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.
node/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Fri, 19 Jun 2026 07:14:38 GMT
11
+ * Last updated: Wed, 01 Jul 2026 11:03:38 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
node/buffer.d.ts CHANGED
@@ -1550,11 +1550,12 @@ declare module "node:buffer" {
1550
1550
  /**
1551
1551
  * If `value` is:
1552
1552
  *
1553
- * * a string, `value` is interpreted according to the character encoding in `encoding`.
1554
- * * a `Buffer` or [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), `value` will be used in its entirety.
1555
- * To compare a partial `Buffer`, use `buf.subarray`.
1553
+ * * a string, `value` is interpreted according to the character encoding in
1554
+ * `encoding`.
1555
+ * * a `Buffer` or `Uint8Array`, `value` will be used in its entirety.
1556
+ * To compare a partial `Buffer`, use `buf.subarray`.
1556
1557
  * * a number, `value` will be interpreted as an unsigned 8-bit integer
1557
- * value between `0` and `255`.
1558
+ * value between `0` and `255`.
1558
1559
  *
1559
1560
  * ```js
1560
1561
  * import { Buffer } from 'node:buffer';
@@ -1582,12 +1583,13 @@ declare module "node:buffer" {
1582
1583
  * // Prints: 6
1583
1584
  * ```
1584
1585
  *
1585
- * If `value` is not a string, number, or `Buffer`, this method will throw a `TypeError`. If `value` is a number, it will be coerced to a valid byte value,
1586
+ * If `value` is not a string, number, or `Buffer`, this method will throw a
1587
+ * `TypeError`. If `value` is a number, it will be coerced to a valid byte value,
1586
1588
  * an integer between 0 and 255.
1587
1589
  *
1588
1590
  * If `byteOffset` is not a number, it will be coerced to a number. If the result
1589
1591
  * of coercion is `NaN` or `0`, then the entire buffer will be searched. This
1590
- * behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf).
1592
+ * behavior matches `String.prototype.indexOf()`.
1591
1593
  *
1592
1594
  * ```js
1593
1595
  * import { Buffer } from 'node:buffer';
@@ -1608,14 +1610,27 @@ declare module "node:buffer" {
1608
1610
  * ```
1609
1611
  *
1610
1612
  * If `value` is an empty string or empty `Buffer` and `byteOffset` is less
1611
- * than `buf.length`, `byteOffset` will be returned. If `value` is empty and`byteOffset` is at least `buf.length`, `buf.length` will be returned.
1613
+ * than `buf.length`, `byteOffset` will be returned. If `value` is empty and
1614
+ * `byteOffset` is at least `buf.length`, `buf.length` will be returned.
1612
1615
  * @since v1.5.0
1613
1616
  * @param value What to search for.
1614
- * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
1615
- * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
1616
- * @return The index of the first occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
1617
- */
1618
- indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
1617
+ * @param start Where to begin searching in `buf`. If negative, then
1618
+ * offset is calculated from the end of `buf`. **Default:** `0`.
1619
+ * @param end Where to stop searching in `buf` (exclusive). **Default:**
1620
+ * `buf.length`.
1621
+ * @param encoding If `value` is a string, this is the encoding used to
1622
+ * determine the binary representation of the string that will be searched for in
1623
+ * `buf`. **Default:** `'utf8'`.
1624
+ * @returns The index of the first occurrence of `value` in `buf`, or
1625
+ * `-1` if `buf` does not contain `value`.
1626
+ */
1627
+ indexOf(
1628
+ value: string | number | Uint8Array,
1629
+ start?: number,
1630
+ end?: number,
1631
+ encoding?: BufferEncoding,
1632
+ ): number;
1633
+ indexOf(value: string | number | Uint8Array, start: number, encoding: BufferEncoding): number;
1619
1634
  indexOf(value: string | number | Uint8Array, encoding: BufferEncoding): number;
1620
1635
  /**
1621
1636
  * Identical to `buf.indexOf()`, except the last occurrence of `value` is found
@@ -1649,12 +1664,13 @@ declare module "node:buffer" {
1649
1664
  * // Prints: 4
1650
1665
  * ```
1651
1666
  *
1652
- * If `value` is not a string, number, or `Buffer`, this method will throw a `TypeError`. If `value` is a number, it will be coerced to a valid byte value,
1667
+ * If `value` is not a string, number, or `Buffer`, this method will throw a
1668
+ * `TypeError`. If `value` is a number, it will be coerced to a valid byte value,
1653
1669
  * an integer between 0 and 255.
1654
1670
  *
1655
1671
  * If `byteOffset` is not a number, it will be coerced to a number. Any arguments
1656
1672
  * that coerce to `NaN`, like `{}` or `undefined`, will search the whole buffer.
1657
- * This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf).
1673
+ * This behavior matches `String.prototype.lastIndexOf()`.
1658
1674
  *
1659
1675
  * ```js
1660
1676
  * import { Buffer } from 'node:buffer';
@@ -1680,11 +1696,24 @@ declare module "node:buffer" {
1680
1696
  * If `value` is an empty string or empty `Buffer`, `byteOffset` will be returned.
1681
1697
  * @since v6.0.0
1682
1698
  * @param value What to search for.
1683
- * @param [byteOffset=buf.length - 1] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
1684
- * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
1685
- * @return The index of the last occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
1686
- */
1687
- lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
1699
+ * @param start Where to begin searching in `buf`. If negative, then
1700
+ * offset is calculated from the end of `buf`. **Default:**
1701
+ * `buf.length - 1`.
1702
+ * @param end Where to stop searching in `buf` (exclusive). **Default:**
1703
+ * `buf.length`.
1704
+ * @param encoding If `value` is a string, this is the encoding used to
1705
+ * determine the binary representation of the string that will be searched for in
1706
+ * `buf`. **Default:** `'utf8'`.
1707
+ * @returns The index of the last occurrence of `value` in `buf`, or
1708
+ * `-1` if `buf` does not contain `value`.
1709
+ */
1710
+ lastIndexOf(
1711
+ value: string | number | Uint8Array,
1712
+ start?: number,
1713
+ end?: number,
1714
+ encoding?: BufferEncoding,
1715
+ ): number;
1716
+ lastIndexOf(value: string | number | Uint8Array, start: number, encoding: BufferEncoding): number;
1688
1717
  lastIndexOf(value: string | number | Uint8Array, encoding: BufferEncoding): number;
1689
1718
  /**
1690
1719
  * Equivalent to `buf.indexOf() !== -1`.
@@ -1711,12 +1740,22 @@ declare module "node:buffer" {
1711
1740
  * ```
1712
1741
  * @since v5.3.0
1713
1742
  * @param value What to search for.
1714
- * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
1715
- * @param [encoding='utf8'] If `value` is a string, this is its encoding.
1716
- * @return `true` if `value` was found in `buf`, `false` otherwise.
1717
- */
1718
- includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
1719
- includes(value: string | number | Buffer, encoding: BufferEncoding): boolean;
1743
+ * @param start Where to begin searching in `buf`. If negative, then
1744
+ * offset is calculated from the end of `buf`. **Default:** `0`.
1745
+ * @param end Where to stop searching in `buf` (exclusive). **Default:**
1746
+ * `buf.length`.
1747
+ * @param encoding If `value` is a string, this is its encoding.
1748
+ * **Default:** `'utf8'`.
1749
+ * @returns `true` if `value` was found in `buf`, `false` otherwise.
1750
+ */
1751
+ includes(
1752
+ value: string | number | Uint8Array,
1753
+ start?: number,
1754
+ end?: number,
1755
+ encoding?: BufferEncoding,
1756
+ ): boolean;
1757
+ includes(value: string | number | Uint8Array, start: number, encoding: BufferEncoding): boolean;
1758
+ includes(value: string | number | Uint8Array, encoding: BufferEncoding): boolean;
1720
1759
  }
1721
1760
  var Buffer: BufferConstructor;
1722
1761
  }
node/crypto.d.ts CHANGED
@@ -1373,9 +1373,9 @@ declare module "node:crypto" {
1373
1373
  */
1374
1374
  update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): Verify;
1375
1375
  /**
1376
- * Verifies the provided data using the given `object` and `signature`.
1376
+ * Verifies the provided data using the given `key` and `signature`.
1377
1377
  *
1378
- * If `object` is not a `KeyObject`, this function behaves as if `object` had been passed to {@link createPublicKey}. If it is an
1378
+ * If `key` is not a `KeyObject`, this function behaves as if `key` had been passed to {@link createPublicKey}. If it is an
1379
1379
  * object, the following additional properties can be passed:
1380
1380
  *
1381
1381
  * The `signature` argument is the previously calculated signature for the data, in
@@ -1392,7 +1392,7 @@ declare module "node:crypto" {
1392
1392
  * @since v0.1.92
1393
1393
  */
1394
1394
  verify(
1395
- object:
1395
+ key:
1396
1396
  | KeyLike
1397
1397
  | VerifyKeyObjectInput
1398
1398
  | VerifyPublicKeyInput
@@ -1470,8 +1470,10 @@ declare module "node:crypto" {
1470
1470
  * If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.
1471
1471
  *
1472
1472
  * This function is a thin wrapper around [`DH_generate_key()`](https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html). In particular,
1473
- * once a private key has been generated or set, calling this function only updates
1474
- * the public key but does not generate a new private key.
1473
+ * once a private key has been generated or set, calling this function only
1474
+ * recomputes the public key from the existing private key. Since the public key is
1475
+ * determined by the private key, the result will be the same unless the private key
1476
+ * has been changed via `diffieHellman.setPrivateKey()`.
1475
1477
  * @since v0.5.0
1476
1478
  * @param encoding The `encoding` of the return value.
1477
1479
  */
@@ -2997,6 +2999,7 @@ declare module "node:crypto" {
2997
2999
  */
2998
3000
  disableEntropyCache?: boolean | undefined;
2999
3001
  }
3002
+ interface RandomUUIDV7Options extends RandomUUIDOptions {}
3000
3003
  type UUID = `${string}-${string}-${string}-${string}-${string}`;
3001
3004
  /**
3002
3005
  * Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a
@@ -3004,6 +3007,16 @@ declare module "node:crypto" {
3004
3007
  * @since v15.6.0, v14.17.0
3005
3008
  */
3006
3009
  function randomUUID(options?: RandomUUIDOptions): UUID;
3010
+ /**
3011
+ * Generates a random [RFC 9562](https://www.rfc-editor.org/rfc/rfc9562.txt) version 7 UUID. The UUID contains a millisecond
3012
+ * precision Unix timestamp in the most significant 48 bits, followed by
3013
+ * cryptographically secure random bits for the remaining fields, making it
3014
+ * suitable for use as a database key with time-based sorting. The embedded
3015
+ * timestamp relies on a non-monotonic clock and is not guaranteed to be strictly
3016
+ * increasing.
3017
+ * @since v26.1.0
3018
+ */
3019
+ function randomUUIDv7(options?: RandomUUIDV7Options): UUID;
3007
3020
  interface X509CheckOptions {
3008
3021
  subject?: "always" | "default" | "never" | undefined;
3009
3022
  wildcards?: boolean | undefined;
@@ -33,7 +33,10 @@ declare module "node:diagnostics_channel" {
33
33
  * @param name The channel name
34
34
  * @return The named channel object
35
35
  */
36
- function channel(name: string | symbol): Channel;
36
+ // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
37
+ function channel<ContextType = any, StoreType = ContextType>(
38
+ name: string | symbol,
39
+ ): Channel<ContextType, StoreType>;
37
40
  type ChannelListener = (message: unknown, name: string | symbol) => void;
38
41
  /**
39
42
  * Register a message handler to subscribe to this channel. This message handler
@@ -96,12 +99,39 @@ declare module "node:diagnostics_channel" {
96
99
  * @param nameOrChannels Channel name or object containing all the `TracingChannel Channels`
97
100
  * @return Collection of channels to trace with
98
101
  */
99
- function tracingChannel<
100
- StoreType = unknown,
101
- ContextType extends object = StoreType extends object ? StoreType : object,
102
- >(
103
- nameOrChannels: string | TracingChannelCollection<StoreType, ContextType>,
104
- ): TracingChannel<StoreType, ContextType>;
102
+ function tracingChannel<ContextType extends object = object, StoreType = ContextType>(
103
+ nameOrChannels: string | TracingChannelCollection<ContextType, StoreType>,
104
+ ): TracingChannel<ContextType, StoreType>;
105
+ /**
106
+ * Creates a {@link BoundedChannel} wrapper for the given channels. If a name is
107
+ * given, the corresponding channels will be created in the form of
108
+ * `tracing:${name}:${eventType}` where `eventType` is `start` or `end`.
109
+ *
110
+ * A `BoundedChannel` is a simplified version of {@link TracingChannel} that only
111
+ * traces synchronous operations. It only has `start` and `end` events, without
112
+ * `asyncStart`, `asyncEnd`, or `error` events, making it suitable for tracing
113
+ * operations that don't involve asynchronous continuations or error handling.
114
+ *
115
+ * ```js
116
+ * import { boundedChannel, channel } from 'node:diagnostics_channel';
117
+ *
118
+ * const wc = boundedChannel('my-operation');
119
+ *
120
+ * // or...
121
+ *
122
+ * const wc2 = boundedChannel({
123
+ * start: channel('tracing:my-operation:start'),
124
+ * end: channel('tracing:my-operation:end'),
125
+ * });
126
+ * ```
127
+ * @since v26.1.0
128
+ * @experimental
129
+ * @param nameOrChannels Channel name or
130
+ * object containing all the [BoundedChannel Channels](https://nodejs.org/docs/latest-v26.x/api/diagnostics_channel.html#boundedchannel-channels)
131
+ */
132
+ function boundedChannel<ContextType extends object = object, StoreType = ContextType>(
133
+ nameOrChannels: string | BoundedChannelCollection<ContextType, StoreType>,
134
+ ): BoundedChannel<ContextType, StoreType>;
105
135
  /**
106
136
  * The class `Channel` represents an individual named channel within the data
107
137
  * pipeline. It is used to track subscribers and to publish messages when there
@@ -111,7 +141,8 @@ declare module "node:diagnostics_channel" {
111
141
  * with `new Channel(name)` is not supported.
112
142
  * @since v15.1.0, v14.17.0
113
143
  */
114
- class Channel<StoreType = unknown, ContextType = StoreType> {
144
+ class Channel<ContextType = any, StoreType = ContextType> {
145
+ private constructor();
115
146
  readonly name: string | symbol;
116
147
  /**
117
148
  * Check if there are active subscribers to this channel. This is helpful if
@@ -132,7 +163,6 @@ declare module "node:diagnostics_channel" {
132
163
  * @since v15.1.0, v14.17.0
133
164
  */
134
165
  readonly hasSubscribers: boolean;
135
- private constructor(name: string | symbol);
136
166
  /**
137
167
  * Publish a message to any subscribers to the channel. This will trigger
138
168
  * message handlers synchronously so they will execute within the same context.
@@ -277,7 +307,48 @@ declare module "node:diagnostics_channel" {
277
307
  thisArg?: ThisArg,
278
308
  ...args: Args
279
309
  ): Result;
310
+ /**
311
+ * Creates a disposable scope that binds the given data to any AsyncLocalStorage
312
+ * instances bound to the channel and publishes it to subscribers. The scope
313
+ * automatically restores the previous storage contexts when disposed.
314
+ *
315
+ * This method enables the use of JavaScript's explicit resource management
316
+ * (`using` syntax with `Symbol.dispose`) to manage store contexts without
317
+ * closure wrapping.
318
+ *
319
+ * ```js
320
+ * import { channel } from 'node:diagnostics_channel';
321
+ * import { AsyncLocalStorage } from 'node:async_hooks';
322
+ *
323
+ * const store = new AsyncLocalStorage();
324
+ * const ch = channel('my-channel');
325
+ *
326
+ * ch.bindStore(store, (message) => {
327
+ * return { ...message, timestamp: Date.now() };
328
+ * });
329
+ *
330
+ * {
331
+ * using scope = ch.withStoreScope({ request: 'data' });
332
+ * // Store is entered, data is published
333
+ * console.log(store.getStore()); // { request: 'data', timestamp: ... }
334
+ * }
335
+ * // Store is automatically restored on scope exit
336
+ * ```
337
+ * @since v26.1.0
338
+ * @experimental
339
+ */
340
+ withStoreScope(data: ContextType): RunStoresScope;
280
341
  }
342
+ /**
343
+ * The class `RunStoresScope` represents a disposable scope created by
344
+ * `channel.withStoreScope(data)`. It manages the lifecycle of store
345
+ * contexts and ensures they are properly restored when the scope exits.
346
+ *
347
+ * The scope must be used with the `using` syntax to ensure proper disposal.
348
+ * @since v26.1.0
349
+ * @experimental
350
+ */
351
+ interface RunStoresScope extends Disposable {}
281
352
  interface TracingChannelSubscribers<ContextType extends object> {
282
353
  start: (message: ContextType) => void;
283
354
  end: (
@@ -304,12 +375,12 @@ declare module "node:diagnostics_channel" {
304
375
  },
305
376
  ) => void;
306
377
  }
307
- interface TracingChannelCollection<StoreType = unknown, ContextType = StoreType> {
308
- start: Channel<StoreType, ContextType>;
309
- end: Channel<StoreType, ContextType>;
310
- asyncStart: Channel<StoreType, ContextType>;
311
- asyncEnd: Channel<StoreType, ContextType>;
312
- error: Channel<StoreType, ContextType>;
378
+ interface TracingChannelCollection<ContextType extends object = object, StoreType = ContextType> {
379
+ start: Channel<ContextType, StoreType>;
380
+ end: Channel<ContextType, StoreType>;
381
+ asyncStart: Channel<ContextType, StoreType>;
382
+ asyncEnd: Channel<ContextType, StoreType>;
383
+ error: Channel<ContextType, StoreType>;
313
384
  }
314
385
  /**
315
386
  * The class `TracingChannel` is a collection of `TracingChannel Channels` which
@@ -320,12 +391,9 @@ declare module "node:diagnostics_channel" {
320
391
  * @since v19.9.0
321
392
  * @experimental
322
393
  */
323
- class TracingChannel<StoreType = unknown, ContextType extends object = {}> implements TracingChannelCollection {
324
- start: Channel<StoreType, ContextType>;
325
- end: Channel<StoreType, ContextType>;
326
- asyncStart: Channel<StoreType, ContextType>;
327
- asyncEnd: Channel<StoreType, ContextType>;
328
- error: Channel<StoreType, ContextType>;
394
+ interface TracingChannel<ContextType extends object = object, StoreType = ContextType>
395
+ extends TracingChannelCollection<ContextType, StoreType>
396
+ {
329
397
  /**
330
398
  * Helper to subscribe a collection of functions to the corresponding channels.
331
399
  * This is the same as calling `channel.subscribe(onMessage)` on each channel
@@ -358,7 +426,7 @@ declare module "node:diagnostics_channel" {
358
426
  * @experimental
359
427
  * @param subscribers Set of `TracingChannel Channels` subscribers
360
428
  */
361
- subscribe(subscribers: TracingChannelSubscribers<ContextType>): void;
429
+ subscribe(subscribers: NodeJS.PartialOptions<TracingChannelSubscribers<ContextType>>): void;
362
430
  /**
363
431
  * Helper to unsubscribe a collection of functions from the corresponding channels.
364
432
  * This is the same as calling `channel.unsubscribe(onMessage)` on each channel
@@ -392,7 +460,7 @@ declare module "node:diagnostics_channel" {
392
460
  * @param subscribers Set of `TracingChannel Channels` subscribers
393
461
  * @return `true` if all handlers were successfully unsubscribed, and `false` otherwise.
394
462
  */
395
- unsubscribe(subscribers: TracingChannelSubscribers<ContextType>): void;
463
+ unsubscribe(subscribers: NodeJS.PartialOptions<TracingChannelSubscribers<ContextType>>): void;
396
464
  /**
397
465
  * Trace a synchronous function call. This will always produce a `start event` and `end event` around the execution and may produce an `error event` if the given function throws an error.
398
466
  * This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all
@@ -557,6 +625,169 @@ declare module "node:diagnostics_channel" {
557
625
  */
558
626
  readonly hasSubscribers: boolean;
559
627
  }
628
+ interface BoundedChannelSubscribers<ContextType extends object> {
629
+ start: (message: ContextType) => void;
630
+ end: (message: ContextType) => void;
631
+ }
632
+ interface BoundedChannelCollection<ContextType extends object = object, StoreType = ContextType> {
633
+ start: Channel<ContextType, StoreType>;
634
+ end: Channel<ContextType, StoreType>;
635
+ }
636
+ /**
637
+ * The class `BoundedChannel` is a simplified version of {@link TracingChannel} that
638
+ * only traces synchronous operations. It consists of two channels (`start` and
639
+ * `end`) instead of five, omitting the `asyncStart`, `asyncEnd`, and `error`
640
+ * events. This makes it suitable for tracing operations that don't involve
641
+ * asynchronous continuations or error handling.
642
+ *
643
+ * Like `TracingChannel`, it is recommended to create and reuse a single
644
+ * `BoundedChannel` at the top-level of the file rather than creating them
645
+ * dynamically.
646
+ * @since v26.1.0
647
+ * @experimental
648
+ */
649
+ interface BoundedChannel<ContextType extends object = object, StoreType = ContextType>
650
+ extends BoundedChannelCollection<ContextType, StoreType>
651
+ {
652
+ /**
653
+ * Check if any of the `start` or `end` channels have subscribers.
654
+ *
655
+ * ```js
656
+ * import { boundedChannel } from 'node:diagnostics_channel';
657
+ *
658
+ * const wc = boundedChannel('my-operation');
659
+ *
660
+ * if (wc.hasSubscribers) {
661
+ * // There are subscribers, perform traced operation
662
+ * }
663
+ * ```
664
+ * @since v26.1.0
665
+ */
666
+ readonly hasSubscribers: boolean;
667
+ /**
668
+ * Subscribe to the bounded channel events. This is equivalent to calling
669
+ * [`channel.subscribe(onMessage)`][] on each channel individually.
670
+ *
671
+ * ```mjs
672
+ * import { boundedChannel } from 'node:diagnostics_channel';
673
+ *
674
+ * const wc = boundedChannel('my-operation');
675
+ *
676
+ * wc.subscribe({
677
+ * start(message) {
678
+ * // Handle start
679
+ * },
680
+ * end(message) {
681
+ * // Handle end
682
+ * },
683
+ * });
684
+ * ```
685
+ * @since v26.1.0
686
+ * @param handlers Set of channel subscribers
687
+ */
688
+ subscribe(handlers: NodeJS.PartialOptions<BoundedChannelSubscribers<ContextType>>): void;
689
+ /**
690
+ * Unsubscribe from the bounded channel events. This is equivalent to calling
691
+ * [`channel.unsubscribe(onMessage)`][] on each channel individually.
692
+ *
693
+ * ```js
694
+ * import { boundedChannel } from 'node:diagnostics_channel';
695
+ *
696
+ * const wc = boundedChannel('my-operation');
697
+ *
698
+ * const handlers = {
699
+ * start(message) {},
700
+ * end(message) {},
701
+ * };
702
+ *
703
+ * wc.subscribe(handlers);
704
+ * wc.unsubscribe(handlers);
705
+ * ```
706
+ * @since v26.1.0
707
+ * @param handlers Set of channel subscribers
708
+ * @returns `true` if all handlers were successfully unsubscribed,
709
+ * `false` otherwise.
710
+ */
711
+ unsubscribe(handlers: NodeJS.PartialOptions<BoundedChannelSubscribers<ContextType>>): boolean;
712
+ /**
713
+ * Trace a synchronous function call. This will produce a `start` event and `end`
714
+ * event around the execution. This runs the given function using
715
+ * [`channel.runStores(context, ...)`][] on the `start` channel which ensures all
716
+ * events have any bound stores set to match this trace context.
717
+ *
718
+ * ```js
719
+ * import { boundedChannel } from 'node:diagnostics_channel';
720
+ *
721
+ * const wc = boundedChannel('my-operation');
722
+ *
723
+ * const result = wc.run({ operationId: '123' }, () => {
724
+ * // Perform operation
725
+ * return 42;
726
+ * });
727
+ * ```
728
+ * @since v26.1.0
729
+ * @param context Shared object to correlate events through
730
+ * @param fn Function to wrap a trace around
731
+ * @param thisArg The receiver to be used for the function call
732
+ * @param args Optional arguments to pass to the function
733
+ * @returns The return value of the given function
734
+ */
735
+ run<ThisArg = any, Args extends any[] = any[], Result = any>(
736
+ fn: (this: ThisArg, ...args: Args) => Result,
737
+ context?: ContextType,
738
+ thisArg?: ThisArg,
739
+ ...args: Args
740
+ ): Result;
741
+ /**
742
+ * Create a disposable scope for tracing a synchronous operation using JavaScript's
743
+ * explicit resource management (`using` syntax). The scope automatically publishes
744
+ * `start` and `end` events, enters bound stores, and handles cleanup when disposed.
745
+ *
746
+ * ```js
747
+ * import { boundedChannel } from 'node:diagnostics_channel';
748
+ *
749
+ * const wc = boundedChannel('my-operation');
750
+ *
751
+ * const context = { operationId: '123' };
752
+ * {
753
+ * using scope = wc.withScope(context);
754
+ * // Stores are entered, start event is published
755
+ *
756
+ * // Perform work and set result on context
757
+ * context.result = 42;
758
+ * }
759
+ * // End event is published, stores are restored automatically
760
+ * ```
761
+ * @since v26.1.0
762
+ * @param context Shared object to correlate events through
763
+ * @returns Disposable scope object
764
+ */
765
+ withScope(context: ContextType): BoundedChannelScope;
766
+ }
767
+ /**
768
+ * The class `BoundedChannelScope` represents a disposable scope created by
769
+ * `boundedChannel.withScope(context)`. It manages the lifecycle of a traced
770
+ * operation, automatically publishing events and managing store contexts.
771
+ *
772
+ * The scope must be used with the `using` syntax to ensure proper disposal.
773
+ *
774
+ * ```js
775
+ * import { boundedChannel } from 'node:diagnostics_channel';
776
+ *
777
+ * const wc = boundedChannel('my-operation');
778
+ *
779
+ * const context = {};
780
+ * {
781
+ * using scope = wc.withScope(context);
782
+ * // Start event is published, stores are entered
783
+ * context.result = performOperation();
784
+ * // End event is automatically published at end of block
785
+ * }
786
+ * ```
787
+ * @since v26.1.0
788
+ * @experimental
789
+ */
790
+ interface BoundedChannelScope extends Disposable {}
560
791
  }
561
792
  declare module "diagnostics_channel" {
562
793
  export * from "node:diagnostics_channel";
node/dns.d.ts CHANGED
@@ -34,7 +34,7 @@ declare module "node:dns" {
34
34
  */
35
35
  all?: boolean | undefined;
36
36
  /**
37
- * When `verbatim`, the resolved addresses are return unsorted. When `ipv4first`, the resolved addresses are sorted
37
+ * When `verbatim`, the resolved addresses are returned unsorted. When `ipv4first`, the resolved addresses are sorted
38
38
  * by placing IPv4 addresses before IPv6 addresses. When `ipv6first`, the resolved addresses are sorted by placing IPv6
39
39
  * addresses before IPv4 addresses. Default value is configurable using
40
40
  * {@link setDefaultResultOrder} or [`--dns-result-order`](https://nodejs.org/docs/latest-v26.x/api/cli.html#--dns-result-orderorder).