@types/node 20.11.4 → 20.11.6

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: Tue, 16 Jan 2024 09:07:05 GMT
11
+ * Last updated: Wed, 24 Jan 2024 06:08:24 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
node/fs.d.ts CHANGED
@@ -281,7 +281,7 @@ declare module "fs" {
281
281
  * Asynchronously close the directory's underlying resource handle.
282
282
  * Subsequent reads will result in errors.
283
283
  *
284
- * A promise is returned that will be resolved after the resource has been
284
+ * A promise is returned that will be fulfilled after the resource has been
285
285
  * closed.
286
286
  * @since v12.12.0
287
287
  */
@@ -296,7 +296,7 @@ declare module "fs" {
296
296
  /**
297
297
  * Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an `fs.Dirent`.
298
298
  *
299
- * A promise is returned that will be resolved with an `fs.Dirent`, or `null`if there are no more directory entries to read.
299
+ * A promise is returned that will be fulfilled with an `fs.Dirent`, or `null`if there are no more directory entries to read.
300
300
  *
301
301
  * Directory entries returned by this function are in no particular order as
302
302
  * provided by the operating system's underlying directory mechanisms.
@@ -354,31 +354,51 @@ declare module "fs" {
354
354
  * @since v0.5.8
355
355
  */
356
356
  close(): void;
357
+ /**
358
+ * When called, requests that the Node.js event loop _not_ exit so long as the `fs.FSWatcher` is active. Calling `watcher.ref()` multiple times will have
359
+ * no effect.
360
+ *
361
+ * By default, all `fs.FSWatcher` objects are "ref'ed", making it normally
362
+ * unnecessary to call `watcher.ref()` unless `watcher.unref()` had been
363
+ * called previously.
364
+ * @since v14.3.0, v12.20.0
365
+ */
366
+ ref(): this;
367
+ /**
368
+ * When called, the active `fs.FSWatcher` object will not require the Node.js
369
+ * event loop to remain active. If there is no other activity keeping the
370
+ * event loop running, the process may exit before the `fs.FSWatcher` object's
371
+ * callback is invoked. Calling `watcher.unref()` multiple times will have
372
+ * no effect.
373
+ * @since v14.3.0, v12.20.0
374
+ */
375
+ unref(): this;
357
376
  /**
358
377
  * events.EventEmitter
359
378
  * 1. change
360
- * 2. error
379
+ * 2. close
380
+ * 3. error
361
381
  */
362
382
  addListener(event: string, listener: (...args: any[]) => void): this;
363
383
  addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
364
- addListener(event: "error", listener: (error: Error) => void): this;
365
384
  addListener(event: "close", listener: () => void): this;
385
+ addListener(event: "error", listener: (error: Error) => void): this;
366
386
  on(event: string, listener: (...args: any[]) => void): this;
367
387
  on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
368
- on(event: "error", listener: (error: Error) => void): this;
369
388
  on(event: "close", listener: () => void): this;
389
+ on(event: "error", listener: (error: Error) => void): this;
370
390
  once(event: string, listener: (...args: any[]) => void): this;
371
391
  once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
372
- once(event: "error", listener: (error: Error) => void): this;
373
392
  once(event: "close", listener: () => void): this;
393
+ once(event: "error", listener: (error: Error) => void): this;
374
394
  prependListener(event: string, listener: (...args: any[]) => void): this;
375
395
  prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
376
- prependListener(event: "error", listener: (error: Error) => void): this;
377
396
  prependListener(event: "close", listener: () => void): this;
397
+ prependListener(event: "error", listener: (error: Error) => void): this;
378
398
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
379
399
  prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
380
- prependOnceListener(event: "error", listener: (error: Error) => void): this;
381
400
  prependOnceListener(event: "close", listener: () => void): this;
401
+ prependOnceListener(event: "error", listener: (error: Error) => void): this;
382
402
  }
383
403
  /**
384
404
  * Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "20.11.4",
3
+ "version": "20.11.6",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -224,7 +224,7 @@
224
224
  "dependencies": {
225
225
  "undici-types": "~5.26.4"
226
226
  },
227
- "typesPublisherContentHash": "0bdb6c09ff6e5c7ea9efdc866ce3750191f1ee5b29fe8e02af32eb863e910dd9",
227
+ "typesPublisherContentHash": "4672df994f41fe8261bb8674f0ae453a191329e23938a5bf005572caa3a878fc",
228
228
  "typeScriptVersion": "4.6",
229
229
  "nonNpm": true
230
230
  }
node/stream/web.d.ts CHANGED
@@ -342,7 +342,23 @@ declare module "stream/web" {
342
342
  }
343
343
  const TextDecoderStream: {
344
344
  prototype: TextDecoderStream;
345
- new(label?: string, options?: TextDecoderOptions): TextDecoderStream;
345
+ new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream;
346
+ };
347
+ interface CompressionStream<R = any, W = any> {
348
+ readonly readable: ReadableStream<R>;
349
+ readonly writable: WritableStream<W>;
350
+ }
351
+ const CompressionStream: {
352
+ prototype: CompressionStream;
353
+ new<R = any, W = any>(format: string): CompressionStream<R, W>;
354
+ };
355
+ interface DecompressionStream<R = any, W = any> {
356
+ readonly readable: ReadableStream<R>;
357
+ readonly writable: WritableStream<W>;
358
+ }
359
+ const DecompressionStream: {
360
+ prototype: DecompressionStream;
361
+ new<R = any, W = any>(format: string): DecompressionStream<R, W>;
346
362
  };
347
363
  }
348
364
  declare module "node:stream/web" {
node/test.d.ts CHANGED
@@ -1012,13 +1012,19 @@ declare module "node:test" {
1012
1012
  */
1013
1013
  restore(): void;
1014
1014
  }
1015
- type Timer = "setInterval" | "clearInterval" | "setTimeout" | "clearTimeout";
1015
+ type Timer = "setInterval" | "setTimeout" | "setImmediate" | "Date";
1016
+
1017
+ interface MockTimersOptions {
1018
+ apis: Timer[];
1019
+ now?: number | Date;
1020
+ }
1016
1021
  /**
1017
1022
  * Mocking timers is a technique commonly used in software testing to simulate and
1018
1023
  * control the behavior of timers, such as `setInterval` and `setTimeout`,
1019
1024
  * without actually waiting for the specified time intervals.
1020
1025
  *
1021
- * MockTimers is also able to mock the `Date` object.
1026
+ * The MockTimers API also allows for mocking of the `Date` constructor and
1027
+ * `setImmediate`/`clearImmediate` functions.
1022
1028
  *
1023
1029
  * The `MockTracker` provides a top-level `timers` export
1024
1030
  * which is a `MockTimers` instance.
@@ -1039,11 +1045,12 @@ declare module "node:test" {
1039
1045
  *
1040
1046
  * ```js
1041
1047
  * import { mock } from 'node:test';
1042
- * mock.timers.enable({ apis: ['setInterval'] });
1048
+ * mock.timers.enable({ apis: ['setInterval', 'Date'], now: 1234 });
1043
1049
  * ```
1044
1050
  *
1045
- * The above example enables mocking for the `setInterval` timer and
1046
- * implicitly mocks the `clearInterval` function. Only the `setInterval`and `clearInterval` functions from `node:timers`,`node:timers/promises`, and`globalThis` will be mocked.
1051
+ * The above example enables mocking for the `Date` constructor, `setInterval` timer and
1052
+ * implicitly mocks the `clearInterval` function. Only the `Date` constructor from `globalThis`,
1053
+ * `setInterval` and `clearInterval` functions from `node:timers`,`node:timers/promises`, and `globalThis` will be mocked.
1047
1054
  *
1048
1055
  * Example usage with initial time set
1049
1056
  *
@@ -1061,12 +1068,36 @@ declare module "node:test" {
1061
1068
  *
1062
1069
  * Alternatively, if you call `mock.timers.enable()` without any parameters:
1063
1070
  *
1064
- * All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`)
1065
- * will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`functions from `node:timers`, `node:timers/promises`,
1066
- * and `globalThis` will be mocked. As well as the global `Date` object.
1071
+ * All timers (`'setInterval'`, `'clearInterval'`, `'Date'`, `'setImmediate'`, `'clearImmediate'`, `'setTimeout'`, and `'clearTimeout'`)
1072
+ * will be mocked.
1073
+ *
1074
+ * The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout` functions from `node:timers`, `node:timers/promises`,
1075
+ * and `globalThis` will be mocked.
1076
+ * The `Date` constructor from `globalThis` will be mocked.
1077
+ *
1078
+ * If there is no initial epoch set, the initial date will be based on 0 in the Unix epoch. This is `January 1st, 1970, 00:00:00 UTC`. You can set an initial date by passing a now property to the `.enable()` method. This value will be used as the initial date for the mocked Date object. It can either be a positive integer, or another Date object.
1067
1079
  * @since v20.4.0
1068
1080
  */
1069
- enable(timers?: Timer[]): void;
1081
+ enable(options?: MockTimersOptions): void;
1082
+ /**
1083
+ * You can use the `.setTime()` method to manually move the mocked date to another time. This method only accepts a positive integer.
1084
+ * Note: This method will execute any mocked timers that are in the past from the new time.
1085
+ * In the below example we are setting a new time for the mocked date.
1086
+ * ```js
1087
+ * import assert from 'node:assert';
1088
+ * import { test } from 'node:test';
1089
+ * test('sets the time of a date object', (context) => {
1090
+ * // Optionally choose what to mock
1091
+ * context.mock.timers.enable({ apis: ['Date'], now: 100 });
1092
+ * assert.strictEqual(Date.now(), 100);
1093
+ * // Advance in time will also advance the date
1094
+ * context.mock.timers.setTime(1000);
1095
+ * context.mock.timers.tick(200);
1096
+ * assert.strictEqual(Date.now(), 1200);
1097
+ * });
1098
+ * ```
1099
+ */
1100
+ setTime(time: number): void;
1070
1101
  /**
1071
1102
  * This function restores the default behavior of all mocks that were previously
1072
1103
  * created by this `MockTimers` instance and disassociates the mocks
node/ts4.8/fs.d.ts CHANGED
@@ -281,7 +281,7 @@ declare module "fs" {
281
281
  * Asynchronously close the directory's underlying resource handle.
282
282
  * Subsequent reads will result in errors.
283
283
  *
284
- * A promise is returned that will be resolved after the resource has been
284
+ * A promise is returned that will be fulfilled after the resource has been
285
285
  * closed.
286
286
  * @since v12.12.0
287
287
  */
@@ -296,7 +296,7 @@ declare module "fs" {
296
296
  /**
297
297
  * Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an `fs.Dirent`.
298
298
  *
299
- * A promise is returned that will be resolved with an `fs.Dirent`, or `null`if there are no more directory entries to read.
299
+ * A promise is returned that will be fulfilled with an `fs.Dirent`, or `null`if there are no more directory entries to read.
300
300
  *
301
301
  * Directory entries returned by this function are in no particular order as
302
302
  * provided by the operating system's underlying directory mechanisms.
@@ -354,31 +354,51 @@ declare module "fs" {
354
354
  * @since v0.5.8
355
355
  */
356
356
  close(): void;
357
+ /**
358
+ * When called, requests that the Node.js event loop _not_ exit so long as the `fs.FSWatcher` is active. Calling `watcher.ref()` multiple times will have
359
+ * no effect.
360
+ *
361
+ * By default, all `fs.FSWatcher` objects are "ref'ed", making it normally
362
+ * unnecessary to call `watcher.ref()` unless `watcher.unref()` had been
363
+ * called previously.
364
+ * @since v14.3.0, v12.20.0
365
+ */
366
+ ref(): this;
367
+ /**
368
+ * When called, the active `fs.FSWatcher` object will not require the Node.js
369
+ * event loop to remain active. If there is no other activity keeping the
370
+ * event loop running, the process may exit before the `fs.FSWatcher` object's
371
+ * callback is invoked. Calling `watcher.unref()` multiple times will have
372
+ * no effect.
373
+ * @since v14.3.0, v12.20.0
374
+ */
375
+ unref(): this;
357
376
  /**
358
377
  * events.EventEmitter
359
378
  * 1. change
360
- * 2. error
379
+ * 2. close
380
+ * 3. error
361
381
  */
362
382
  addListener(event: string, listener: (...args: any[]) => void): this;
363
383
  addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
364
- addListener(event: "error", listener: (error: Error) => void): this;
365
384
  addListener(event: "close", listener: () => void): this;
385
+ addListener(event: "error", listener: (error: Error) => void): this;
366
386
  on(event: string, listener: (...args: any[]) => void): this;
367
387
  on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
368
- on(event: "error", listener: (error: Error) => void): this;
369
388
  on(event: "close", listener: () => void): this;
389
+ on(event: "error", listener: (error: Error) => void): this;
370
390
  once(event: string, listener: (...args: any[]) => void): this;
371
391
  once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
372
- once(event: "error", listener: (error: Error) => void): this;
373
392
  once(event: "close", listener: () => void): this;
393
+ once(event: "error", listener: (error: Error) => void): this;
374
394
  prependListener(event: string, listener: (...args: any[]) => void): this;
375
395
  prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
376
- prependListener(event: "error", listener: (error: Error) => void): this;
377
396
  prependListener(event: "close", listener: () => void): this;
397
+ prependListener(event: "error", listener: (error: Error) => void): this;
378
398
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
379
399
  prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
380
- prependOnceListener(event: "error", listener: (error: Error) => void): this;
381
400
  prependOnceListener(event: "close", listener: () => void): this;
401
+ prependOnceListener(event: "error", listener: (error: Error) => void): this;
382
402
  }
383
403
  /**
384
404
  * Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.
@@ -342,7 +342,23 @@ declare module "stream/web" {
342
342
  }
343
343
  const TextDecoderStream: {
344
344
  prototype: TextDecoderStream;
345
- new(label?: string, options?: TextDecoderOptions): TextDecoderStream;
345
+ new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream;
346
+ };
347
+ interface CompressionStream<R = any, W = any> {
348
+ readonly readable: ReadableStream<R>;
349
+ readonly writable: WritableStream<W>;
350
+ }
351
+ const CompressionStream: {
352
+ prototype: CompressionStream;
353
+ new<R = any, W = any>(format: string): CompressionStream<R, W>;
354
+ };
355
+ interface DecompressionStream<R = any, W = any> {
356
+ readonly readable: ReadableStream<R>;
357
+ readonly writable: WritableStream<W>;
358
+ }
359
+ const DecompressionStream: {
360
+ prototype: DecompressionStream;
361
+ new<R = any, W = any>(format: string): DecompressionStream<R, W>;
346
362
  };
347
363
  }
348
364
  declare module "node:stream/web" {
node/ts4.8/test.d.ts CHANGED
@@ -1012,13 +1012,19 @@ declare module "node:test" {
1012
1012
  */
1013
1013
  restore(): void;
1014
1014
  }
1015
- type Timer = "setInterval" | "clearInterval" | "setTimeout" | "clearTimeout";
1015
+ type Timer = "setInterval" | "setTimeout" | "setImmediate" | "Date";
1016
+
1017
+ interface MockTimersOptions {
1018
+ apis: Timer[];
1019
+ now?: number | Date;
1020
+ }
1016
1021
  /**
1017
1022
  * Mocking timers is a technique commonly used in software testing to simulate and
1018
1023
  * control the behavior of timers, such as `setInterval` and `setTimeout`,
1019
1024
  * without actually waiting for the specified time intervals.
1020
1025
  *
1021
- * MockTimers is also able to mock the `Date` object.
1026
+ * The MockTimers API also allows for mocking of the `Date` constructor and
1027
+ * `setImmediate`/`clearImmediate` functions.
1022
1028
  *
1023
1029
  * The `MockTracker` provides a top-level `timers` export
1024
1030
  * which is a `MockTimers` instance.
@@ -1039,11 +1045,12 @@ declare module "node:test" {
1039
1045
  *
1040
1046
  * ```js
1041
1047
  * import { mock } from 'node:test';
1042
- * mock.timers.enable({ apis: ['setInterval'] });
1048
+ * mock.timers.enable({ apis: ['setInterval', 'Date'], now: 1234 });
1043
1049
  * ```
1044
1050
  *
1045
- * The above example enables mocking for the `setInterval` timer and
1046
- * implicitly mocks the `clearInterval` function. Only the `setInterval`and `clearInterval` functions from `node:timers`,`node:timers/promises`, and`globalThis` will be mocked.
1051
+ * The above example enables mocking for the `Date` constructor, `setInterval` timer and
1052
+ * implicitly mocks the `clearInterval` function. Only the `Date` constructor from `globalThis`,
1053
+ * `setInterval` and `clearInterval` functions from `node:timers`,`node:timers/promises`, and `globalThis` will be mocked.
1047
1054
  *
1048
1055
  * Example usage with initial time set
1049
1056
  *
@@ -1061,12 +1068,36 @@ declare module "node:test" {
1061
1068
  *
1062
1069
  * Alternatively, if you call `mock.timers.enable()` without any parameters:
1063
1070
  *
1064
- * All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`)
1065
- * will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`functions from `node:timers`, `node:timers/promises`,
1066
- * and `globalThis` will be mocked. As well as the global `Date` object.
1071
+ * All timers (`'setInterval'`, `'clearInterval'`, `'Date'`, `'setImmediate'`, `'clearImmediate'`, `'setTimeout'`, and `'clearTimeout'`)
1072
+ * will be mocked.
1073
+ *
1074
+ * The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout` functions from `node:timers`, `node:timers/promises`,
1075
+ * and `globalThis` will be mocked.
1076
+ * The `Date` constructor from `globalThis` will be mocked.
1077
+ *
1078
+ * If there is no initial epoch set, the initial date will be based on 0 in the Unix epoch. This is `January 1st, 1970, 00:00:00 UTC`. You can set an initial date by passing a now property to the `.enable()` method. This value will be used as the initial date for the mocked Date object. It can either be a positive integer, or another Date object.
1067
1079
  * @since v20.4.0
1068
1080
  */
1069
- enable(timers?: Timer[]): void;
1081
+ enable(options?: MockTimersOptions): void;
1082
+ /**
1083
+ * You can use the `.setTime()` method to manually move the mocked date to another time. This method only accepts a positive integer.
1084
+ * Note: This method will execute any mocked timers that are in the past from the new time.
1085
+ * In the below example we are setting a new time for the mocked date.
1086
+ * ```js
1087
+ * import assert from 'node:assert';
1088
+ * import { test } from 'node:test';
1089
+ * test('sets the time of a date object', (context) => {
1090
+ * // Optionally choose what to mock
1091
+ * context.mock.timers.enable({ apis: ['Date'], now: 100 });
1092
+ * assert.strictEqual(Date.now(), 100);
1093
+ * // Advance in time will also advance the date
1094
+ * context.mock.timers.setTime(1000);
1095
+ * context.mock.timers.tick(200);
1096
+ * assert.strictEqual(Date.now(), 1200);
1097
+ * });
1098
+ * ```
1099
+ */
1100
+ setTime(time: number): void;
1070
1101
  /**
1071
1102
  * This function restores the default behavior of all mocks that were previously
1072
1103
  * created by this `MockTimers` instance and disassociates the mocks