@types/node
Advanced tools
Comparing version 20.11.4 to 20.11.5
{ | ||
"name": "@types/node", | ||
"version": "20.11.4", | ||
"version": "20.11.5", | ||
"description": "TypeScript definitions for node", | ||
@@ -227,5 +227,5 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node", | ||
}, | ||
"typesPublisherContentHash": "0bdb6c09ff6e5c7ea9efdc866ce3750191f1ee5b29fe8e02af32eb863e910dd9", | ||
"typesPublisherContentHash": "c9a4069d05b7343bb761470d8e688010c07b955f2242b07b710e067f1720f96a", | ||
"typeScriptVersion": "4.6", | ||
"nonNpm": true | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
### Additional Details | ||
* Last updated: Tue, 16 Jan 2024 09:07:05 GMT | ||
* Last updated: Wed, 17 Jan 2024 06:36:16 GMT | ||
* Dependencies: [undici-types](https://npmjs.com/package/undici-types) | ||
@@ -14,0 +14,0 @@ |
@@ -345,4 +345,20 @@ declare module "stream/web" { | ||
prototype: TextDecoderStream; | ||
new(label?: string, options?: TextDecoderOptions): TextDecoderStream; | ||
new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream; | ||
}; | ||
interface CompressionStream<R = any, W = any> { | ||
readonly readable: ReadableStream<R>; | ||
readonly writable: WritableStream<W>; | ||
} | ||
const CompressionStream: { | ||
prototype: CompressionStream; | ||
new<R = any, W = any>(format: string): CompressionStream<R, W>; | ||
}; | ||
interface DecompressionStream<R = any, W = any> { | ||
readonly readable: ReadableStream<R>; | ||
readonly writable: WritableStream<W>; | ||
} | ||
const DecompressionStream: { | ||
prototype: DecompressionStream; | ||
new<R = any, W = any>(format: string): DecompressionStream<R, W>; | ||
}; | ||
} | ||
@@ -349,0 +365,0 @@ declare module "node:stream/web" { |
@@ -1015,3 +1015,8 @@ /** | ||
} | ||
type Timer = "setInterval" | "clearInterval" | "setTimeout" | "clearTimeout"; | ||
type Timer = "setInterval" | "setTimeout" | "setImmediate" | "Date"; | ||
interface MockTimersOptions { | ||
apis: Timer[]; | ||
now?: number | Date; | ||
} | ||
/** | ||
@@ -1022,3 +1027,4 @@ * Mocking timers is a technique commonly used in software testing to simulate and | ||
* | ||
* MockTimers is also able to mock the `Date` object. | ||
* The MockTimers API also allows for mocking of the `Date` constructor and | ||
* `setImmediate`/`clearImmediate` functions. | ||
* | ||
@@ -1044,7 +1050,8 @@ * The `MockTracker` provides a top-level `timers` export | ||
* import { mock } from 'node:test'; | ||
* mock.timers.enable({ apis: ['setInterval'] }); | ||
* mock.timers.enable({ apis: ['setInterval', 'Date'], now: 1234 }); | ||
* ``` | ||
* | ||
* The above example enables mocking for the `setInterval` timer and | ||
* implicitly mocks the `clearInterval` function. Only the `setInterval`and `clearInterval` functions from `node:timers`,`node:timers/promises`, and`globalThis` will be mocked. | ||
* The above example enables mocking for the `Date` constructor, `setInterval` timer and | ||
* implicitly mocks the `clearInterval` function. Only the `Date` constructor from `globalThis`, | ||
* `setInterval` and `clearInterval` functions from `node:timers`,`node:timers/promises`, and `globalThis` will be mocked. | ||
* | ||
@@ -1067,9 +1074,33 @@ * Example usage with initial time set | ||
* | ||
* All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`) | ||
* will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`functions from `node:timers`, `node:timers/promises`, | ||
* and `globalThis` will be mocked. As well as the global `Date` object. | ||
* All timers (`'setInterval'`, `'clearInterval'`, `'Date'`, `'setImmediate'`, `'clearImmediate'`, `'setTimeout'`, and `'clearTimeout'`) | ||
* will be mocked. | ||
* | ||
* The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout` functions from `node:timers`, `node:timers/promises`, | ||
* and `globalThis` will be mocked. | ||
* The `Date` constructor from `globalThis` will be mocked. | ||
* | ||
* 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. | ||
* @since v20.4.0 | ||
*/ | ||
enable(timers?: Timer[]): void; | ||
enable(options?: MockTimersOptions): void; | ||
/** | ||
* You can use the `.setTime()` method to manually move the mocked date to another time. This method only accepts a positive integer. | ||
* Note: This method will execute any mocked timers that are in the past from the new time. | ||
* In the below example we are setting a new time for the mocked date. | ||
* ```js | ||
* import assert from 'node:assert'; | ||
* import { test } from 'node:test'; | ||
* test('sets the time of a date object', (context) => { | ||
* // Optionally choose what to mock | ||
* context.mock.timers.enable({ apis: ['Date'], now: 100 }); | ||
* assert.strictEqual(Date.now(), 100); | ||
* // Advance in time will also advance the date | ||
* context.mock.timers.setTime(1000); | ||
* context.mock.timers.tick(200); | ||
* assert.strictEqual(Date.now(), 1200); | ||
* }); | ||
* ``` | ||
*/ | ||
setTime(time: number): void; | ||
/** | ||
* This function restores the default behavior of all mocks that were previously | ||
@@ -1076,0 +1107,0 @@ * created by this `MockTimers` instance and disassociates the mocks |
@@ -345,4 +345,20 @@ declare module "stream/web" { | ||
prototype: TextDecoderStream; | ||
new(label?: string, options?: TextDecoderOptions): TextDecoderStream; | ||
new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream; | ||
}; | ||
interface CompressionStream<R = any, W = any> { | ||
readonly readable: ReadableStream<R>; | ||
readonly writable: WritableStream<W>; | ||
} | ||
const CompressionStream: { | ||
prototype: CompressionStream; | ||
new<R = any, W = any>(format: string): CompressionStream<R, W>; | ||
}; | ||
interface DecompressionStream<R = any, W = any> { | ||
readonly readable: ReadableStream<R>; | ||
readonly writable: WritableStream<W>; | ||
} | ||
const DecompressionStream: { | ||
prototype: DecompressionStream; | ||
new<R = any, W = any>(format: string): DecompressionStream<R, W>; | ||
}; | ||
} | ||
@@ -349,0 +365,0 @@ declare module "node:stream/web" { |
@@ -1015,3 +1015,8 @@ /** | ||
} | ||
type Timer = "setInterval" | "clearInterval" | "setTimeout" | "clearTimeout"; | ||
type Timer = "setInterval" | "setTimeout" | "setImmediate" | "Date"; | ||
interface MockTimersOptions { | ||
apis: Timer[]; | ||
now?: number | Date; | ||
} | ||
/** | ||
@@ -1022,3 +1027,4 @@ * Mocking timers is a technique commonly used in software testing to simulate and | ||
* | ||
* MockTimers is also able to mock the `Date` object. | ||
* The MockTimers API also allows for mocking of the `Date` constructor and | ||
* `setImmediate`/`clearImmediate` functions. | ||
* | ||
@@ -1044,7 +1050,8 @@ * The `MockTracker` provides a top-level `timers` export | ||
* import { mock } from 'node:test'; | ||
* mock.timers.enable({ apis: ['setInterval'] }); | ||
* mock.timers.enable({ apis: ['setInterval', 'Date'], now: 1234 }); | ||
* ``` | ||
* | ||
* The above example enables mocking for the `setInterval` timer and | ||
* implicitly mocks the `clearInterval` function. Only the `setInterval`and `clearInterval` functions from `node:timers`,`node:timers/promises`, and`globalThis` will be mocked. | ||
* The above example enables mocking for the `Date` constructor, `setInterval` timer and | ||
* implicitly mocks the `clearInterval` function. Only the `Date` constructor from `globalThis`, | ||
* `setInterval` and `clearInterval` functions from `node:timers`,`node:timers/promises`, and `globalThis` will be mocked. | ||
* | ||
@@ -1067,9 +1074,33 @@ * Example usage with initial time set | ||
* | ||
* All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`) | ||
* will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`functions from `node:timers`, `node:timers/promises`, | ||
* and `globalThis` will be mocked. As well as the global `Date` object. | ||
* All timers (`'setInterval'`, `'clearInterval'`, `'Date'`, `'setImmediate'`, `'clearImmediate'`, `'setTimeout'`, and `'clearTimeout'`) | ||
* will be mocked. | ||
* | ||
* The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout` functions from `node:timers`, `node:timers/promises`, | ||
* and `globalThis` will be mocked. | ||
* The `Date` constructor from `globalThis` will be mocked. | ||
* | ||
* 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. | ||
* @since v20.4.0 | ||
*/ | ||
enable(timers?: Timer[]): void; | ||
enable(options?: MockTimersOptions): void; | ||
/** | ||
* You can use the `.setTime()` method to manually move the mocked date to another time. This method only accepts a positive integer. | ||
* Note: This method will execute any mocked timers that are in the past from the new time. | ||
* In the below example we are setting a new time for the mocked date. | ||
* ```js | ||
* import assert from 'node:assert'; | ||
* import { test } from 'node:test'; | ||
* test('sets the time of a date object', (context) => { | ||
* // Optionally choose what to mock | ||
* context.mock.timers.enable({ apis: ['Date'], now: 100 }); | ||
* assert.strictEqual(Date.now(), 100); | ||
* // Advance in time will also advance the date | ||
* context.mock.timers.setTime(1000); | ||
* context.mock.timers.tick(200); | ||
* assert.strictEqual(Date.now(), 1200); | ||
* }); | ||
* ``` | ||
*/ | ||
setTime(time: number): void; | ||
/** | ||
* This function restores the default behavior of all mocks that were previously | ||
@@ -1076,0 +1107,0 @@ * created by this `MockTimers` instance and disassociates the mocks |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3981777
89967