@types/node 20.11.4 → 20.11.5
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 +1 -1
- node/package.json +2 -2
- node/stream/web.d.ts +17 -1
- node/test.d.ts +40 -9
- node/ts4.8/stream/web.d.ts +17 -1
- node/ts4.8/test.d.ts +40 -9
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:
|
|
11
|
+
* Last updated: Wed, 17 Jan 2024 06:36:16 GMT
|
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
|
13
13
|
|
|
14
14
|
# Credits
|
node/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "20.11.
|
|
3
|
+
"version": "20.11.5",
|
|
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": "
|
|
227
|
+
"typesPublisherContentHash": "c9a4069d05b7343bb761470d8e688010c07b955f2242b07b710e067f1720f96a",
|
|
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(
|
|
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" | "
|
|
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
|
|
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 `
|
|
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.
|
|
1066
|
-
*
|
|
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(
|
|
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/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(
|
|
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" | "
|
|
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
|
|
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 `
|
|
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.
|
|
1066
|
-
*
|
|
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(
|
|
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
|