@types/node 16.18.78 → 16.18.79

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 v16.18/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/v16.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Wed, 31 Jan 2024 19:35:04 GMT
11
+ * Last updated: Thu, 01 Feb 2024 17:35:23 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "16.18.78",
3
+ "version": "16.18.79",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -222,6 +222,6 @@
222
222
  },
223
223
  "scripts": {},
224
224
  "dependencies": {},
225
- "typesPublisherContentHash": "22a2fa011bf9e331acc51df56038056b552f8b9da6edd88d5c123bc5952476ff",
225
+ "typesPublisherContentHash": "052d62dae6ffb01bc2ee31005dcedbade3b7287f6e0ea97a6302c5d2fd41aec9",
226
226
  "typeScriptVersion": "4.6"
227
227
  }
@@ -1205,11 +1205,13 @@ declare module "crypto" {
1205
1205
  format?: KeyFormat | undefined;
1206
1206
  type?: "pkcs1" | "pkcs8" | "sec1" | undefined;
1207
1207
  passphrase?: string | Buffer | undefined;
1208
+ encoding?: string | undefined;
1208
1209
  }
1209
1210
  interface PublicKeyInput {
1210
1211
  key: string | Buffer;
1211
1212
  format?: KeyFormat | undefined;
1212
1213
  type?: "pkcs1" | "spki" | undefined;
1214
+ encoding?: string | undefined;
1213
1215
  }
1214
1216
  /**
1215
1217
  * Asynchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`.
@@ -3490,12 +3492,13 @@ declare module "crypto" {
3490
3492
  */
3491
3493
  disableEntropyCache?: boolean | undefined;
3492
3494
  }
3495
+ type UUID = `${string}-${string}-${string}-${string}-${string}`;
3493
3496
  /**
3494
3497
  * Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a
3495
3498
  * cryptographic pseudorandom number generator.
3496
3499
  * @since v15.6.0
3497
3500
  */
3498
- function randomUUID(options?: RandomUUIDOptions): string;
3501
+ function randomUUID(options?: RandomUUIDOptions): UUID;
3499
3502
  interface X509CheckOptions {
3500
3503
  /**
3501
3504
  * @default 'always'
@@ -3978,7 +3981,7 @@ declare module "crypto" {
3978
3981
  * The UUID is generated using a cryptographic pseudorandom number generator.
3979
3982
  * @since v16.7.0
3980
3983
  */
3981
- randomUUID(): string;
3984
+ randomUUID(): UUID;
3982
3985
  CryptoKey: CryptoKeyConstructor;
3983
3986
  }
3984
3987
  // This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable.
@@ -57,6 +57,7 @@ declare module "diagnostics_channel" {
57
57
  * @return The named channel object
58
58
  */
59
59
  function channel(name: string | symbol): Channel;
60
+ type ChannelListener = (message: unknown, name: string | symbol) => void;
60
61
  /**
61
62
  * Register a message handler to subscribe to this channel. This message handler will be run synchronously
62
63
  * whenever a message is published to the channel. Any errors thrown in the message handler will
@@ -96,7 +97,6 @@ declare module "diagnostics_channel" {
96
97
  * @returns `true` if the handler was found, `false` otherwise
97
98
  */
98
99
  function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean;
99
- type ChannelListener = (message: unknown, name: string | symbol) => void;
100
100
  /**
101
101
  * The class `Channel` represents an individual named channel within the data
102
102
  * pipeline. It is use to track subscribers and to publish messages when there
@@ -353,6 +353,7 @@ declare module "dns/promises" {
353
353
  resolve4: typeof resolve4;
354
354
  resolve6: typeof resolve6;
355
355
  resolveAny: typeof resolveAny;
356
+ resolveCaa: typeof resolveCaa;
356
357
  resolveCname: typeof resolveCname;
357
358
  resolveMx: typeof resolveMx;
358
359
  resolveNaptr: typeof resolveNaptr;
@@ -761,6 +761,7 @@ declare module "dns" {
761
761
  resolve4: typeof resolve4;
762
762
  resolve6: typeof resolve6;
763
763
  resolveAny: typeof resolveAny;
764
+ resolveCaa: typeof resolveCaa;
764
765
  resolveCname: typeof resolveCname;
765
766
  resolveMx: typeof resolveMx;
766
767
  resolveNaptr: typeof resolveNaptr;
@@ -35,6 +35,8 @@
35
35
  * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/events.js)
36
36
  */
37
37
  declare module "events" {
38
+ import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
39
+
38
40
  interface EventEmitterOptions {
39
41
  /**
40
42
  * Enables automatic capturing of promise rejection.
@@ -72,6 +74,9 @@ declare module "events" {
72
74
  */
73
75
  class EventEmitter {
74
76
  constructor(options?: EventEmitterOptions);
77
+
78
+ [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void;
79
+
75
80
  /**
76
81
  * Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
77
82
  * event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
@@ -314,10 +319,54 @@ declare module "events" {
314
319
  */
315
320
  signal?: AbortSignal | undefined;
316
321
  }
322
+
323
+ export interface EventEmitterReferencingAsyncResource extends AsyncResource {
324
+ readonly eventEmitter: EventEmitterAsyncResource;
325
+ }
326
+
327
+ export interface EventEmitterAsyncResourceOptions extends AsyncResourceOptions, EventEmitterOptions {
328
+ /**
329
+ * The type of async event, this is required when instantiating `EventEmitterAsyncResource`
330
+ * directly rather than as a child class.
331
+ * @default new.target.name if instantiated as a child class.
332
+ */
333
+ name?: string;
334
+ }
335
+
336
+ /**
337
+ * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that require
338
+ * manual async tracking. Specifically, all events emitted by instances of
339
+ * `EventEmitterAsyncResource` will run within its async context.
340
+ *
341
+ * The EventEmitterAsyncResource class has the same methods and takes the
342
+ * same options as EventEmitter and AsyncResource themselves.
343
+ * @throws if `options.name` is not provided when instantiated directly.
344
+ * @since v17.4.0, v16.14.0
345
+ */
346
+ export class EventEmitterAsyncResource extends EventEmitter {
347
+ /**
348
+ * @param options Only optional in child class.
349
+ */
350
+ constructor(options?: EventEmitterAsyncResourceOptions);
351
+ /**
352
+ * Call all destroy hooks. This should only ever be called once. An
353
+ * error will be thrown if it is called more than once. This must be
354
+ * manually called. If the resource is left to be collected by the GC then
355
+ * the destroy hooks will never be called.
356
+ */
357
+ emitDestroy(): void;
358
+ /** The unique asyncId assigned to the resource. */
359
+ readonly asyncId: number;
360
+ /** The same triggerAsyncId that is passed to the AsyncResource constructor. */
361
+ readonly triggerAsyncId: number;
362
+ /** The underlying AsyncResource */
363
+ readonly asyncResource: EventEmitterReferencingAsyncResource;
364
+ }
317
365
  }
318
366
  global {
319
367
  namespace NodeJS {
320
368
  interface EventEmitter {
369
+ [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void;
321
370
  /**
322
371
  * Alias for `emitter.on(eventName, listener)`.
323
372
  * @since v0.1.26
@@ -42,6 +42,7 @@
42
42
  declare module "http" {
43
43
  import * as stream from "node:stream";
44
44
  import { URL } from "node:url";
45
+ import { EventEmitter } from "node:events";
45
46
  import { LookupFunction, Server as NetServer, Socket, TcpSocketConnectOpts } from "node:net";
46
47
  // incoming headers will never contain number
47
48
  interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> {
@@ -1216,9 +1217,9 @@ declare module "http" {
1216
1217
  * ```
1217
1218
  * @since v0.3.4
1218
1219
  */
1219
- class Agent {
1220
+ class Agent extends EventEmitter {
1220
1221
  /**
1221
- * By default set to 256\. For agents with `keepAlive` enabled, this
1222
+ * By default set to 256. For agents with `keepAlive` enabled, this
1222
1223
  * sets the maximum number of sockets that will be left open in the free
1223
1224
  * state.
1224
1225
  * @since v0.11.7
@@ -22,7 +22,7 @@
22
22
  * IN THE SOFTWARE.
23
23
  */
24
24
 
25
- // NOTE: These definitions support NodeJS and TypeScript 4.8 and earlier
25
+ // NOTE: These definitions support NodeJS and TypeScript 4.9+.
26
26
 
27
27
  // Reference required types from the default lib:
28
28
  /// <reference lib="es2020" />
@@ -28,7 +28,6 @@ declare module "os" {
28
28
  }
29
29
  interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
30
30
  family: "IPv4";
31
- scopeid?: undefined;
32
31
  }
33
32
  interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
34
33
  family: "IPv6";
@@ -30,7 +30,7 @@
30
30
  */
31
31
  declare module "perf_hooks" {
32
32
  import { AsyncResource } from "node:async_hooks";
33
- type EntryType = "node" | "mark" | "measure" | "gc" | "function" | "http2" | "http";
33
+ type EntryType = "node" | "mark" | "measure" | "gc" | "function" | "http2" | "http" | "dns";
34
34
  interface NodeGCPerformanceDetail {
35
35
  /**
36
36
  * When `performanceEntry.entryType` is equal to 'gc', `the performance.kind` property identifies
@@ -18,7 +18,7 @@
18
18
  */
19
19
  declare module "stream" {
20
20
  import { Abortable, EventEmitter } from "node:events";
21
- import { Blob } from "node:buffer";
21
+ import { Blob as NodeBlob } from "node:buffer";
22
22
  import * as streamPromises from "node:stream/promises";
23
23
  import * as streamConsumers from "node:stream/consumers";
24
24
  class internal extends EventEmitter {
@@ -45,6 +45,12 @@ declare module "stream" {
45
45
  encoding?: BufferEncoding | undefined;
46
46
  read?(this: Readable, size: number): void;
47
47
  }
48
+ interface ArrayOptions {
49
+ /** the maximum concurrent invocations of `fn` to call on the stream at once. **Default: 1**. */
50
+ concurrency?: number;
51
+ /** allows destroying the stream if the signal is aborted. */
52
+ signal?: AbortSignal;
53
+ }
48
54
  /**
49
55
  * @since v0.9.4
50
56
  */
@@ -397,6 +403,36 @@ declare module "stream" {
397
403
  */
398
404
  wrap(stream: NodeJS.ReadableStream): this;
399
405
  push(chunk: any, encoding?: BufferEncoding): boolean;
406
+ /**
407
+ * The iterator created by this method gives users the option to cancel the destruction
408
+ * of the stream if the `for await...of` loop is exited by `return`, `break`, or `throw`,
409
+ * or if the iterator should destroy the stream if the stream emitted an error during iteration.
410
+ * @since v16.3.0
411
+ * @param options.destroyOnReturn When set to `false`, calling `return` on the async iterator,
412
+ * or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream.
413
+ * **Default: `true`**.
414
+ */
415
+ iterator(options?: { destroyOnReturn?: boolean }): AsyncIterableIterator<any>;
416
+ /**
417
+ * This method allows mapping over the stream. The *fn* function will be called for every chunk in the stream.
418
+ * If the *fn* function returns a promise - that promise will be `await`ed before being passed to the result stream.
419
+ * @since v17.4.0, v16.14.0
420
+ * @param fn a function to map over every chunk in the stream. Async or not.
421
+ * @returns a stream mapped with the function *fn*.
422
+ */
423
+ map(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => any, options?: ArrayOptions): Readable;
424
+ /**
425
+ * This method allows filtering the stream. For each chunk in the stream the *fn* function will be called
426
+ * and if it returns a truthy value, the chunk will be passed to the result stream.
427
+ * If the *fn* function returns a promise - that promise will be `await`ed.
428
+ * @since v17.4.0, v16.14.0
429
+ * @param fn a function to filter chunks from the stream. Async or not.
430
+ * @returns a stream filtered with the predicate *fn*.
431
+ */
432
+ filter(
433
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>,
434
+ options?: ArrayOptions,
435
+ ): Readable;
400
436
  _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
401
437
  /**
402
438
  * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the readable
@@ -848,7 +884,7 @@ declare module "stream" {
848
884
  static from(
849
885
  src:
850
886
  | Stream
851
- | Blob
887
+ | NodeBlob
852
888
  | ArrayBuffer
853
889
  | string
854
890
  | Iterable<any>