Deploy Production Code for Commit a8bd9aef18 🚀

This commit is contained in:
James Ives 2023-07-12 01:42:33 +00:00
parent a8bd9aef18
commit a1ea191d50
32 changed files with 1356 additions and 447 deletions

2
node_modules/@types/node/README.md generated vendored
View File

@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node. Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
### Additional Details ### Additional Details
* Last updated: Thu, 25 May 2023 20:34:26 GMT * Last updated: Fri, 07 Jul 2023 23:02:42 GMT
* Dependencies: none * Dependencies: none
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone` * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`

11
node_modules/@types/node/buffer.d.ts generated vendored
View File

@ -299,6 +299,10 @@ declare module 'buffer' {
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
* ``` * ```
* *
* If `array` is an `Array`\-like object (that is, one with a `length` property of
* type `number`), it is treated as if it is an array, unless it is a `Buffer` or
* a `Uint8Array`. This means all other `TypedArray` variants get treated as an`Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use `Buffer.copyBytesFrom()`.
*
* A `TypeError` will be thrown if `array` is not an `Array` or another type * A `TypeError` will be thrown if `array` is not an `Array` or another type
* appropriate for `Buffer.from()` variants. * appropriate for `Buffer.from()` variants.
* *
@ -526,7 +530,7 @@ declare module 'buffer' {
* @param [fill=0] A value to pre-fill the new `Buffer` with. * @param [fill=0] A value to pre-fill the new `Buffer` with.
* @param [encoding='utf8'] If `fill` is a string, this is its encoding. * @param [encoding='utf8'] If `fill` is a string, this is its encoding.
*/ */
alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer; alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer;
/** /**
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
* *
@ -550,9 +554,8 @@ declare module 'buffer' {
* A `TypeError` will be thrown if `size` is not a number. * A `TypeError` will be thrown if `size` is not a number.
* *
* The `Buffer` module pre-allocates an internal `Buffer` instance of * The `Buffer` module pre-allocates an internal `Buffer` instance of
* size `Buffer.poolSize` that is used as a pool for the fast allocation of new`Buffer` instances created using `Buffer.allocUnsafe()`,`Buffer.from(array)`, `Buffer.concat()`, and the * size `Buffer.poolSize` that is used as a pool for the fast allocation of new`Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
* deprecated`new Buffer(size)` constructor only when `size` is less than or equal * and `Buffer.concat()` only when `size` is less than or equal to`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
* to `Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
* *
* Use of this pre-allocated internal memory pool is a key difference between * Use of this pre-allocated internal memory pool is a key difference between
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`. * calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.

View File

@ -56,6 +56,7 @@ declare module 'cluster' {
import * as child from 'node:child_process'; import * as child from 'node:child_process';
import EventEmitter = require('node:events'); import EventEmitter = require('node:events');
import * as net from 'node:net'; import * as net from 'node:net';
type SerializationType = 'json' | 'advanced';
export interface ClusterSettings { export interface ClusterSettings {
execArgv?: string[] | undefined; // default: process.execArgv execArgv?: string[] | undefined; // default: process.execArgv
exec?: string | undefined; exec?: string | undefined;
@ -65,6 +66,9 @@ declare module 'cluster' {
uid?: number | undefined; uid?: number | undefined;
gid?: number | undefined; gid?: number | undefined;
inspectPort?: number | (() => number) | undefined; inspectPort?: number | (() => number) | undefined;
serialization?: SerializationType | undefined;
cwd?: string | undefined;
windowsHide?: boolean | undefined;
} }
export interface Address { export interface Address {
address: string; address: string;

36
node_modules/@types/node/crypto.d.ts generated vendored
View File

@ -21,14 +21,14 @@ declare module 'crypto' {
import { PeerCertificate } from 'node:tls'; import { PeerCertificate } from 'node:tls';
/** /**
* SPKAC is a Certificate Signing Request mechanism originally implemented by * SPKAC is a Certificate Signing Request mechanism originally implemented by
* Netscape and was specified formally as part of [HTML5's `keygen` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/keygen). * Netscape and was specified formally as part of HTML5's `keygen` element.
* *
* `<keygen>` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects * `<keygen>` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects
* should not use this element anymore. * should not use this element anymore.
* *
* The `node:crypto` module provides the `Certificate` class for working with SPKAC * The `node:crypto` module provides the `Certificate` class for working with SPKAC
* data. The most common usage is handling output generated by the HTML5`<keygen>` element. Node.js uses [OpenSSL's SPKAC * data. The most common usage is handling output generated by the HTML5`<keygen>` element. Node.js uses [OpenSSL's SPKAC
* implementation](https://www.openssl.org/docs/man1.1.0/apps/openssl-spkac.html) internally. * implementation](https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html) internally.
* @since v0.11.8 * @since v0.11.8
*/ */
class Certificate { class Certificate {
@ -223,7 +223,9 @@ declare module 'crypto' {
* display the available digest algorithms. * display the available digest algorithms.
* *
* The `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is * The `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is
* a `KeyObject`, its type must be `secret`. * a `KeyObject`, its type must be `secret`. If it is a string, please consider `caveats when using strings as inputs to cryptographic APIs`. If it was
* obtained from a cryptographically secure source of entropy, such as {@link randomBytes} or {@link generateKey}, its length should not
* exceed the block size of `algorithm` (e.g., 512 bits for SHA-256).
* *
* Example: generating the sha256 HMAC of a file * Example: generating the sha256 HMAC of a file
* *
@ -683,13 +685,13 @@ declare module 'crypto' {
* **GCM, or CCM).** * **GCM, or CCM).**
* *
* The implementation of `crypto.createCipher()` derives keys using the OpenSSL * The implementation of `crypto.createCipher()` derives keys using the OpenSSL
* function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
* iteration, and no salt. The lack of salt allows dictionary attacks as the same * iteration, and no salt. The lack of salt allows dictionary attacks as the same
* password always creates the same key. The low iteration count and * password always creates the same key. The low iteration count and
* non-cryptographically secure hash algorithm allow passwords to be tested very * non-cryptographically secure hash algorithm allow passwords to be tested very
* rapidly. * rapidly.
* *
* In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) it is recommended that * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that
* developers derive a key and IV on * developers derive a key and IV on
* their own using {@link scrypt} and to use {@link createCipheriv} to create the `Cipher` object. Users should not use ciphers with counter mode * their own using {@link scrypt} and to use {@link createCipheriv} to create the `Cipher` object. Users should not use ciphers with counter mode
* (e.g. CTR, GCM, or CCM) in `crypto.createCipher()`. A warning is emitted when * (e.g. CTR, GCM, or CCM) in `crypto.createCipher()`. A warning is emitted when
@ -944,13 +946,13 @@ declare module 'crypto' {
* **GCM, or CCM).** * **GCM, or CCM).**
* *
* The implementation of `crypto.createDecipher()` derives keys using the OpenSSL * The implementation of `crypto.createDecipher()` derives keys using the OpenSSL
* function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
* iteration, and no salt. The lack of salt allows dictionary attacks as the same * iteration, and no salt. The lack of salt allows dictionary attacks as the same
* password always creates the same key. The low iteration count and * password always creates the same key. The low iteration count and
* non-cryptographically secure hash algorithm allow passwords to be tested very * non-cryptographically secure hash algorithm allow passwords to be tested very
* rapidly. * rapidly.
* *
* In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) it is recommended that * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that
* developers derive a key and IV on * developers derive a key and IV on
* their own using {@link scrypt} and to use {@link createDecipheriv} to create the `Decipher` object. * their own using {@link scrypt} and to use {@link createDecipheriv} to create the `Decipher` object.
* @since v0.1.94 * @since v0.1.94
@ -1195,11 +1197,14 @@ declare module 'crypto' {
* generateKey, * generateKey,
* } = await import('node:crypto'); * } = await import('node:crypto');
* *
* generateKey('hmac', { length: 64 }, (err, key) => { * generateKey('hmac', { length: 512 }, (err, key) => {
* if (err) throw err; * if (err) throw err;
* console.log(key.export().toString('hex')); // 46e..........620 * console.log(key.export().toString('hex')); // 46e..........620
* }); * });
* ``` * ```
*
* The size of a generated HMAC key should not exceed the block size of the
* underlying hash function. See {@link createHmac} for more information.
* @since v15.0.0 * @since v15.0.0
* @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`. * @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`.
*/ */
@ -1218,9 +1223,12 @@ declare module 'crypto' {
* generateKeySync, * generateKeySync,
* } = await import('node:crypto'); * } = await import('node:crypto');
* *
* const key = generateKeySync('hmac', { length: 64 }); * const key = generateKeySync('hmac', { length: 512 });
* console.log(key.export().toString('hex')); // e89..........41e * console.log(key.export().toString('hex')); // e89..........41e
* ``` * ```
*
* The size of a generated HMAC key should not exceed the block size of the
* underlying hash function. See {@link createHmac} for more information.
* @since v15.0.0 * @since v15.0.0
* @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`. * @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`.
*/ */
@ -1508,10 +1516,15 @@ declare module 'crypto' {
class DiffieHellman { class DiffieHellman {
private constructor(); private constructor();
/** /**
* Generates private and public Diffie-Hellman key values, and returns * Generates private and public Diffie-Hellman key values unless they have been
* generated or computed already, and returns
* the public key in the specified `encoding`. This key should be * the public key in the specified `encoding`. This key should be
* transferred to the other party. * transferred to the other party.
* If `encoding` is provided a string is returned; otherwise a `Buffer` is returned. * If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.
*
* This function is a thin wrapper around [`DH_generate_key()`](https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html). In particular,
* once a private key has been generated or set, calling this function only updates
* the public key but does not generate a new private key.
* @since v0.5.0 * @since v0.5.0
* @param encoding The `encoding` of the return value. * @param encoding The `encoding` of the return value.
*/ */
@ -1583,6 +1596,9 @@ declare module 'crypto' {
* Sets the Diffie-Hellman private key. If the `encoding` argument is provided,`privateKey` is expected * Sets the Diffie-Hellman private key. If the `encoding` argument is provided,`privateKey` is expected
* to be a string. If no `encoding` is provided, `privateKey` is expected * to be a string. If no `encoding` is provided, `privateKey` is expected
* to be a `Buffer`, `TypedArray`, or `DataView`. * to be a `Buffer`, `TypedArray`, or `DataView`.
*
* This function does not automatically compute the associated public key. Either `diffieHellman.setPublicKey()` or `diffieHellman.generateKeys()` can be
* used to manually provide the public key or to automatically derive it.
* @since v0.5.0 * @since v0.5.0
* @param encoding The `encoding` of the `privateKey` string. * @param encoding The `encoding` of the `privateKey` string.
*/ */

11
node_modules/@types/node/fs.d.ts generated vendored
View File

@ -1632,18 +1632,19 @@ declare module 'fs' {
* *
* The callback is given a possible exception and, if `recursive` is `true`, the * The callback is given a possible exception and, if `recursive` is `true`, the
* first directory path created, `(err[, path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was * first directory path created, `(err[, path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was
* created. * created (for instance, if it was previously created).
* *
* The optional `options` argument can be an integer specifying `mode` (permission * The optional `options` argument can be an integer specifying `mode` (permission
* and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fs.mkdir()` when `path` is a directory that * and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fs.mkdir()` when `path` is a directory that
* exists results in an error only * exists results in an error only
* when `recursive` is false. * when `recursive` is false. If `recursive` is false and the directory exists,
* an `EEXIST` error occurs.
* *
* ```js * ```js
* import { mkdir } from 'node:fs'; * import { mkdir } from 'node:fs';
* *
* // Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist. * // Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist.
* mkdir('/tmp/a/apple', { recursive: true }, (err) => { * mkdir('./tmp/a/apple', { recursive: true }, (err) => {
* if (err) throw err; * if (err) throw err;
* }); * });
* ``` * ```
@ -3088,7 +3089,7 @@ declare module 'fs' {
recursive?: boolean | undefined; recursive?: boolean | undefined;
} }
export type WatchEventType = 'rename' | 'change'; export type WatchEventType = 'rename' | 'change';
export type WatchListener<T> = (event: WatchEventType, filename: T) => void; export type WatchListener<T> = (event: WatchEventType, filename: T | null) => void;
export type StatsListener = (curr: Stats, prev: Stats) => void; export type StatsListener = (curr: Stats, prev: Stats) => void;
export type BigIntStatsListener = (curr: BigIntStats, prev: BigIntStats) => void; export type BigIntStatsListener = (curr: BigIntStats, prev: BigIntStats) => void;
/** /**

View File

@ -43,7 +43,7 @@ declare module 'fs/promises' {
import { Interface as ReadlineInterface } from 'node:readline'; import { Interface as ReadlineInterface } from 'node:readline';
interface FileChangeInfo<T extends string | Buffer> { interface FileChangeInfo<T extends string | Buffer> {
eventType: WatchEventType; eventType: WatchEventType;
filename: T; filename: T | null;
} }
interface FlagAndOpenMode { interface FlagAndOpenMode {
mode?: Mode | undefined; mode?: Mode | undefined;

View File

@ -1,4 +1,4 @@
// Type definitions for non-npm package Node.js 20.2 // Type definitions for non-npm package Node.js 20.4
// Project: https://nodejs.org/ // Project: https://nodejs.org/
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft> // Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
// DefinitelyTyped <https://github.com/DefinitelyTyped> // DefinitelyTyped <https://github.com/DefinitelyTyped>

21
node_modules/@types/node/module.d.ts generated vendored
View File

@ -73,11 +73,24 @@ declare module 'module' {
readonly payload: SourceMapPayload; readonly payload: SourceMapPayload;
constructor(payload: SourceMapPayload); constructor(payload: SourceMapPayload);
/** /**
* Given a line number and column number in the generated source file, returns * Given a line offset and column offset in the generated source
* an object representing the position in the original file. The object returned * file, returns an object representing the SourceMap range in the
* consists of the following keys: * original file if found, or an empty object if not.
*
* The object returned contains the following keys:
*
* The returned value represents the raw range as it appears in the
* SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and
* column numbers as they appear in Error messages and CallSite
* objects.
*
* To get the corresponding 1-indexed line and column numbers from a
* lineNumber and columnNumber as they are reported by Error stacks
* and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)`
* @param lineOffset The zero-indexed line number offset in the generated source
* @param columnOffset The zero-indexed column number offset in the generated source
*/ */
findEntry(line: number, column: number): SourceMapping; findEntry(lineOffset: number, columnOffset: number): SourceMapping;
} }
} }
interface Module extends NodeModule {} interface Module extends NodeModule {}

14
node_modules/@types/node/net.d.ts generated vendored
View File

@ -310,12 +310,14 @@ declare module 'net' {
*/ */
readonly remoteAddress?: string | undefined; readonly remoteAddress?: string | undefined;
/** /**
* The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. * The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. Value may be `undefined` if
* the socket is destroyed (for example, if the client disconnected).
* @since v0.11.14 * @since v0.11.14
*/ */
readonly remoteFamily?: string | undefined; readonly remoteFamily?: string | undefined;
/** /**
* The numeric representation of the remote port. For example, `80` or `21`. * The numeric representation of the remote port. For example, `80` or `21`. Value may be `undefined` if
* the socket is destroyed (for example, if the client disconnected).
* @since v0.5.10 * @since v0.5.10
*/ */
readonly remotePort?: number | undefined; readonly remotePort?: number | undefined;
@ -744,8 +746,8 @@ declare module 'net' {
* *
* Test this by using `telnet`: * Test this by using `telnet`:
* *
* ```console * ```bash
* $ telnet localhost 8124 * telnet localhost 8124
* ``` * ```
* *
* To listen on the socket `/tmp/echo.sock`: * To listen on the socket `/tmp/echo.sock`:
@ -758,8 +760,8 @@ declare module 'net' {
* *
* Use `nc` to connect to a Unix domain socket server: * Use `nc` to connect to a Unix domain socket server:
* *
* ```console * ```bash
* $ nc -U /tmp/echo.sock * nc -U /tmp/echo.sock
* ``` * ```
* @since v0.5.0 * @since v0.5.0
* @param connectionListener Automatically set as a listener for the {@link 'connection'} event. * @param connectionListener Automatically set as a listener for the {@link 'connection'} event.

View File

@ -1,6 +1,6 @@
{ {
"name": "@types/node", "name": "@types/node",
"version": "20.2.4", "version": "20.4.1",
"description": "TypeScript definitions for Node.js", "description": "TypeScript definitions for Node.js",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node", "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
"license": "MIT", "license": "MIT",
@ -232,6 +232,6 @@
}, },
"scripts": {}, "scripts": {},
"dependencies": {}, "dependencies": {},
"typesPublisherContentHash": "2e3b2377433bb56f46cc48c2ae626cac278d92bddb803373733d72c8da681f19", "typesPublisherContentHash": "cd0e2c7a0a92527e46fbda5fc12bd264c97c2b44ff53770b6b8c6a71e3f2b1dd",
"typeScriptVersion": "4.3" "typeScriptVersion": "4.3"
} }

View File

@ -307,8 +307,8 @@ declare module 'process' {
* *
* Launching the Node.js process as: * Launching the Node.js process as:
* *
* ```console * ```bash
* $ node process-args.js one two=three four * node process-args.js one two=three four
* ``` * ```
* *
* Would generate the output: * Would generate the output:
@ -344,8 +344,8 @@ declare module 'process' {
* the script name. These options are useful in order to spawn child processes with * the script name. These options are useful in order to spawn child processes with
* the same execution environment as the parent. * the same execution environment as the parent.
* *
* ```console * ```bash
* $ node --harmony script.js --version * node --harmony script.js --version
* ``` * ```
* *
* Results in `process.execArgv`: * Results in `process.execArgv`:
@ -492,8 +492,8 @@ declare module 'process' {
* to other `Worker` threads. * to other `Worker` threads.
* In other words, the following example would not work: * In other words, the following example would not work:
* *
* ```console * ```bash
* $ node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo * node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo
* ``` * ```
* *
* While the following will: * While the following will:
@ -898,21 +898,30 @@ declare module 'process' {
* Will generate an object similar to: * Will generate an object similar to:
* *
* ```console * ```console
* { node: '11.13.0', * { node: '20.2.0',
* v8: '7.0.276.38-node.18', * acorn: '8.8.2',
* uv: '1.27.0', * ada: '2.4.0',
* zlib: '1.2.11', * ares: '1.19.0',
* brotli: '1.0.7', * base64: '0.5.0',
* ares: '1.15.0', * brotli: '1.0.9',
* modules: '67', * cjs_module_lexer: '1.2.2',
* nghttp2: '1.34.0', * cldr: '43.0',
* napi: '4', * icu: '73.1',
* llhttp: '1.1.1', * llhttp: '8.1.0',
* openssl: '1.1.1b', * modules: '115',
* cldr: '34.0', * napi: '8',
* icu: '63.1', * nghttp2: '1.52.0',
* tz: '2018e', * nghttp3: '0.7.0',
* unicode: '11.0' } * ngtcp2: '0.8.1',
* openssl: '3.0.8+quic',
* simdutf: '3.2.9',
* tz: '2023c',
* undici: '5.22.0',
* unicode: '15.0',
* uv: '1.44.2',
* uvwasi: '0.0.16',
* v8: '11.3.244.8-node.9',
* zlib: '1.2.13' }
* ``` * ```
* @since v0.2.0 * @since v0.2.0
*/ */

617
node_modules/@types/node/test.d.ts generated vendored
View File

@ -159,35 +159,35 @@ declare module 'node:test' {
* @param [name='The name'] The name of the suite, which is displayed when reporting test results. * @param [name='The name'] The name of the suite, which is displayed when reporting test results.
* @param options Configuration options for the suite. supports the same options as `test([name][, options][, fn])`. * @param options Configuration options for the suite. supports the same options as `test([name][, options][, fn])`.
* @param [fn='A no-op function'] The function under suite declaring all subtests and subsuites. The first argument to this function is a {@link SuiteContext} object. * @param [fn='A no-op function'] The function under suite declaring all subtests and subsuites. The first argument to this function is a {@link SuiteContext} object.
* @return `undefined`. * @return Immediately fulfilled with `undefined`.
*/ */
function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void; function describe(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
function describe(name?: string, fn?: SuiteFn): void; function describe(name?: string, fn?: SuiteFn): Promise<void>;
function describe(options?: TestOptions, fn?: SuiteFn): void; function describe(options?: TestOptions, fn?: SuiteFn): Promise<void>;
function describe(fn?: SuiteFn): void; function describe(fn?: SuiteFn): Promise<void>;
namespace describe { namespace describe {
/** /**
* Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`. * Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`.
*/ */
function skip(name?: string, options?: TestOptions, fn?: SuiteFn): void; function skip(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
function skip(name?: string, fn?: SuiteFn): void; function skip(name?: string, fn?: SuiteFn): Promise<void>;
function skip(options?: TestOptions, fn?: SuiteFn): void; function skip(options?: TestOptions, fn?: SuiteFn): Promise<void>;
function skip(fn?: SuiteFn): void; function skip(fn?: SuiteFn): Promise<void>;
/** /**
* Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`. * Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`.
*/ */
function todo(name?: string, options?: TestOptions, fn?: SuiteFn): void; function todo(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
function todo(name?: string, fn?: SuiteFn): void; function todo(name?: string, fn?: SuiteFn): Promise<void>;
function todo(options?: TestOptions, fn?: SuiteFn): void; function todo(options?: TestOptions, fn?: SuiteFn): Promise<void>;
function todo(fn?: SuiteFn): void; function todo(fn?: SuiteFn): Promise<void>;
/** /**
* Shorthand for marking a suite as `only`, same as `describe([name], { only: true }[, fn])`. * Shorthand for marking a suite as `only`, same as `describe([name], { only: true }[, fn])`.
* @since v18.15.0 * @since v18.15.0
*/ */
function only(name?: string, options?: TestOptions, fn?: SuiteFn): void; function only(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
function only(name?: string, fn?: SuiteFn): void; function only(name?: string, fn?: SuiteFn): Promise<void>;
function only(options?: TestOptions, fn?: SuiteFn): void; function only(options?: TestOptions, fn?: SuiteFn): Promise<void>;
function only(fn?: SuiteFn): void; function only(fn?: SuiteFn): Promise<void>;
} }
/** /**
* Shorthand for `test()`. * Shorthand for `test()`.
@ -195,69 +195,69 @@ declare module 'node:test' {
* The `it()` function is imported from the `node:test` module. * The `it()` function is imported from the `node:test` module.
* @since v18.6.0, v16.17.0 * @since v18.6.0, v16.17.0
*/ */
function it(name?: string, options?: TestOptions, fn?: TestFn): void; function it(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
function it(name?: string, fn?: TestFn): void; function it(name?: string, fn?: TestFn): Promise<void>;
function it(options?: TestOptions, fn?: TestFn): void; function it(options?: TestOptions, fn?: TestFn): Promise<void>;
function it(fn?: TestFn): void; function it(fn?: TestFn): Promise<void>;
namespace it { namespace it {
/** /**
* Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`. * Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`.
*/ */
function skip(name?: string, options?: TestOptions, fn?: TestFn): void; function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
function skip(name?: string, fn?: TestFn): void; function skip(name?: string, fn?: TestFn): Promise<void>;
function skip(options?: TestOptions, fn?: TestFn): void; function skip(options?: TestOptions, fn?: TestFn): Promise<void>;
function skip(fn?: TestFn): void; function skip(fn?: TestFn): Promise<void>;
/** /**
* Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`. * Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`.
*/ */
function todo(name?: string, options?: TestOptions, fn?: TestFn): void; function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
function todo(name?: string, fn?: TestFn): void; function todo(name?: string, fn?: TestFn): Promise<void>;
function todo(options?: TestOptions, fn?: TestFn): void; function todo(options?: TestOptions, fn?: TestFn): Promise<void>;
function todo(fn?: TestFn): void; function todo(fn?: TestFn): Promise<void>;
/** /**
* Shorthand for marking a test as `only`, same as `it([name], { only: true }[, fn])`. * Shorthand for marking a test as `only`, same as `it([name], { only: true }[, fn])`.
* @since v18.15.0 * @since v18.15.0
*/ */
function only(name?: string, options?: TestOptions, fn?: TestFn): void; function only(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
function only(name?: string, fn?: TestFn): void; function only(name?: string, fn?: TestFn): Promise<void>;
function only(options?: TestOptions, fn?: TestFn): void; function only(options?: TestOptions, fn?: TestFn): Promise<void>;
function only(fn?: TestFn): void; function only(fn?: TestFn): Promise<void>;
} }
/** /**
* Shorthand for skipping a test, same as `test([name], { skip: true }[, fn])`. * Shorthand for skipping a test, same as `test([name], { skip: true }[, fn])`.
* @since v20.2.0 * @since v20.2.0
*/ */
function skip(name?: string, options?: TestOptions, fn?: TestFn): void; function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
function skip(name?: string, fn?: TestFn): void; function skip(name?: string, fn?: TestFn): Promise<void>;
function skip(options?: TestOptions, fn?: TestFn): void; function skip(options?: TestOptions, fn?: TestFn): Promise<void>;
function skip(fn?: TestFn): void; function skip(fn?: TestFn): Promise<void>;
/** /**
* Shorthand for marking a test as `TODO`, same as `test([name], { todo: true }[, fn])`. * Shorthand for marking a test as `TODO`, same as `test([name], { todo: true }[, fn])`.
* @since v20.2.0 * @since v20.2.0
*/ */
function todo(name?: string, options?: TestOptions, fn?: TestFn): void; function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
function todo(name?: string, fn?: TestFn): void; function todo(name?: string, fn?: TestFn): Promise<void>;
function todo(options?: TestOptions, fn?: TestFn): void; function todo(options?: TestOptions, fn?: TestFn): Promise<void>;
function todo(fn?: TestFn): void; function todo(fn?: TestFn): Promise<void>;
/** /**
* Shorthand for marking a test as `only`, same as `test([name], { only: true }[, fn])`. * Shorthand for marking a test as `only`, same as `test([name], { only: true }[, fn])`.
* @since v20.2.0 * @since v20.2.0
*/ */
function only(name?: string, options?: TestOptions, fn?: TestFn): void; function only(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
function only(name?: string, fn?: TestFn): void; function only(name?: string, fn?: TestFn): Promise<void>;
function only(options?: TestOptions, fn?: TestFn): void; function only(options?: TestOptions, fn?: TestFn): Promise<void>;
function only(fn?: TestFn): void; function only(fn?: TestFn): Promise<void>;
/** /**
* The type of a function under test. The first argument to this function is a * The type of a function under test. The first argument to this function is a
* {@link TestContext} object. If the test uses callbacks, the callback function is passed as * {@link TestContext} object. If the test uses callbacks, the callback function is passed as
* the second argument. * the second argument.
*/ */
type TestFn = (t: TestContext, done: (result?: any) => void) => any; type TestFn = (t: TestContext, done: (result?: any) => void) => void | Promise<void>;
/** /**
* The type of a function under Suite. * The type of a function under Suite.
* If the test uses callbacks, the callback function is passed as an argument * If the test uses callbacks, the callback function is passed as an argument
*/ */
type SuiteFn = (done: (result?: any) => void) => void; type SuiteFn = (s: SuiteContext) => void | Promise<void>;
interface RunOptions { interface RunOptions {
/** /**
* If a number is provided, then that many files would run in parallel. * If a number is provided, then that many files would run in parallel.
@ -307,134 +307,50 @@ declare module 'node:test' {
addListener(event: 'test:pass', listener: (data: TestPass) => void): this; addListener(event: 'test:pass', listener: (data: TestPass) => void): this;
addListener(event: 'test:plan', listener: (data: TestPlan) => void): this; addListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
addListener(event: 'test:start', listener: (data: TestStart) => void): this; addListener(event: 'test:start', listener: (data: TestStart) => void): this;
addListener(event: 'test:stderr', listener: (data: TestStderr) => void): this;
addListener(event: 'test:stdout', listener: (data: TestStdout) => void): this;
addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: string, listener: (...args: any[]) => void): this;
emit(event: 'test:diagnostic', data: DiagnosticData): boolean; emit(event: 'test:diagnostic', data: DiagnosticData): boolean;
emit(event: 'test:fail', data: TestFail): boolean; emit(event: 'test:fail', data: TestFail): boolean;
emit(event: 'test:pass', data: TestPass): boolean; emit(event: 'test:pass', data: TestPass): boolean;
emit(event: 'test:plan', data: TestPlan): boolean; emit(event: 'test:plan', data: TestPlan): boolean;
emit(event: 'test:start', data: TestStart): boolean; emit(event: 'test:start', data: TestStart): boolean;
emit(event: 'test:stderr', data: TestStderr): boolean;
emit(event: 'test:stdout', data: TestStdout): boolean;
emit(event: string | symbol, ...args: any[]): boolean; emit(event: string | symbol, ...args: any[]): boolean;
on(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; on(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
on(event: 'test:fail', listener: (data: TestFail) => void): this; on(event: 'test:fail', listener: (data: TestFail) => void): this;
on(event: 'test:pass', listener: (data: TestPass) => void): this; on(event: 'test:pass', listener: (data: TestPass) => void): this;
on(event: 'test:plan', listener: (data: TestPlan) => void): this; on(event: 'test:plan', listener: (data: TestPlan) => void): this;
on(event: 'test:start', listener: (data: TestStart) => void): this; on(event: 'test:start', listener: (data: TestStart) => void): this;
on(event: 'test:stderr', listener: (data: TestStderr) => void): this;
on(event: 'test:stdout', listener: (data: TestStdout) => void): this;
on(event: string, listener: (...args: any[]) => void): this; on(event: string, listener: (...args: any[]) => void): this;
once(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; once(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
once(event: 'test:fail', listener: (data: TestFail) => void): this; once(event: 'test:fail', listener: (data: TestFail) => void): this;
once(event: 'test:pass', listener: (data: TestPass) => void): this; once(event: 'test:pass', listener: (data: TestPass) => void): this;
once(event: 'test:plan', listener: (data: TestPlan) => void): this; once(event: 'test:plan', listener: (data: TestPlan) => void): this;
once(event: 'test:start', listener: (data: TestStart) => void): this; once(event: 'test:start', listener: (data: TestStart) => void): this;
once(event: 'test:stderr', listener: (data: TestStderr) => void): this;
once(event: 'test:stdout', listener: (data: TestStdout) => void): this;
once(event: string, listener: (...args: any[]) => void): this; once(event: string, listener: (...args: any[]) => void): this;
prependListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; prependListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
prependListener(event: 'test:fail', listener: (data: TestFail) => void): this; prependListener(event: 'test:fail', listener: (data: TestFail) => void): this;
prependListener(event: 'test:pass', listener: (data: TestPass) => void): this; prependListener(event: 'test:pass', listener: (data: TestPass) => void): this;
prependListener(event: 'test:plan', listener: (data: TestPlan) => void): this; prependListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
prependListener(event: 'test:start', listener: (data: TestStart) => void): this; prependListener(event: 'test:start', listener: (data: TestStart) => void): this;
prependListener(event: 'test:stderr', listener: (data: TestStderr) => void): this;
prependListener(event: 'test:stdout', listener: (data: TestStdout) => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; prependOnceListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this; prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this;
prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this; prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this;
prependOnceListener(event: 'test:plan', listener: (data: TestPlan) => void): this; prependOnceListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
prependOnceListener(event: 'test:start', listener: (data: TestStart) => void): this; prependOnceListener(event: 'test:start', listener: (data: TestStart) => void): this;
prependOnceListener(event: 'test:stderr', listener: (data: TestStderr) => void): this;
prependOnceListener(event: 'test:stdout', listener: (data: TestStdout) => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: string, listener: (...args: any[]) => void): this;
} }
interface DiagnosticData {
/**
* The diagnostic message.
*/
message: string;
/**
* The nesting level of the test.
*/
nesting: number;
}
interface TestFail {
/**
* Additional execution metadata.
*/
details: {
/**
* The duration of the test in milliseconds.
*/
duration: number;
/**
* The error thrown by the test.
*/
error: Error;
};
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The ordinal number of the test.
*/
testNumber: number;
/**
* Present if `context.todo` is called.
*/
todo?: string | boolean;
/**
* Present if `context.skip` is called.
*/
skip?: string | boolean;
}
interface TestPass {
/**
* Additional execution metadata.
*/
details: {
/**
* The duration of the test in milliseconds.
*/
duration: number;
};
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The ordinal number of the test.
*/
testNumber: number;
/**
* Present if `context.todo` is called.
*/
todo?: string | boolean;
/**
* Present if `context.skip` is called.
*/
skip?: string | boolean;
}
interface TestPlan {
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The number of subtests that have ran.
*/
count: number;
}
interface TestStart {
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
}
/** /**
* An instance of `TestContext` is passed to each test function in order to * An instance of `TestContext` is passed to each test function in order to
* interact with the test runner. However, the `TestContext` constructor is not * interact with the test runner. However, the `TestContext` constructor is not
@ -570,6 +486,24 @@ declare module 'node:test' {
*/ */
readonly mock: MockTracker; readonly mock: MockTracker;
} }
/**
* An instance of `SuiteContext` is passed to each suite function in order to
* interact with the test runner. However, the `SuiteContext` constructor is not
* exposed as part of the API.
* @since v18.7.0, v16.17.0
*/
class SuiteContext {
/**
* The name of the suite.
* @since v18.8.0, v16.18.0
*/
readonly name: string;
/**
* Can be used to abort test subtasks when the test has been aborted.
* @since v18.7.0, v16.17.0
*/
readonly signal: AbortSignal;
}
interface TestOptions { interface TestOptions {
/** /**
* If a number is provided, then that many tests would run in parallel. * If a number is provided, then that many tests would run in parallel.
@ -905,6 +839,7 @@ declare module 'node:test' {
* @since v19.1.0, v18.13.0 * @since v19.1.0, v18.13.0
*/ */
restoreAll(): void; restoreAll(): void;
timers: MockTimers;
} }
const mock: MockTracker; const mock: MockTracker;
interface MockFunctionCall< interface MockFunctionCall<
@ -1048,5 +983,401 @@ declare module 'node:test' {
*/ */
restore(): void; restore(): void;
} }
type Timer = 'setInterval' | 'clearInterval' | 'setTimeout' | 'clearTimeout';
/**
* Mocking timers is a technique commonly used in software testing to simulate and
* control the behavior of timers, such as `setInterval` and `setTimeout`,
* without actually waiting for the specified time intervals.
*
* The `MockTracker` provides a top-level `timers` export
* which is a `MockTimers` instance.
* @since v20.4.0
* @experimental
*/
class MockTimers {
/**
* Enables timer mocking for the specified timers.
*
* **Note:** When you enable mocking for a specific timer, its associated
* clear function will also be implicitly mocked.
*
* Example usage:
*
* ```js
* import { mock } from 'node:test';
* mock.timers.enable(['setInterval']);
* ```
*
* ```js
* const { mock } = require('node:test');
* mock.timers.enable(['setInterval']);
* ```
*
* 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.
*
* Alternatively, if you call `mock.timers.enable()` without any parameters:
*
* 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.
* @since v20.4.0
*/
enable(timers?: Timer[]): void;
/**
* This function restores the default behavior of all mocks that were previously
* created by this `MockTimers` instance and disassociates the mocks
* from the `MockTracker` instance.
*
* **Note:** After each test completes, this function is called on
* the test context's `MockTracker`.
*
* ```js
* import { mock } from 'node:test';
* mock.timers.reset();
* ```
*
* ```js
* const { mock } = require('node:test');
* mock.timers.reset();
* ```
* @since v20.4.0
*/
reset(): void;
/**
* Advances time for all mocked timers.
*
* **Note:** This diverges from how `setTimeout` in Node.js behaves and accepts
* only positive numbers. In Node.js, `setTimeout` with negative numbers is
* only supported for web compatibility reasons.
*
* The following example mocks a `setTimeout` function and
* by using `.tick` advances in
* time triggering all pending timers.
*
* ```js
* import assert from 'node:assert';
* import { test } from 'node:test';
*
* test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {
* const fn = context.mock.fn();
*
* context.mock.timers.enable(['setTimeout']);
*
* setTimeout(fn, 9999);
*
* assert.strictEqual(fn.mock.callCount(), 0);
*
* // Advance in time
* context.mock.timers.tick(9999);
*
* assert.strictEqual(fn.mock.callCount(), 1);
* });
* ```
*
* ```js
* const assert = require('node:assert');
* const { test } = require('node:test');
*
* test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {
* const fn = context.mock.fn();
* context.mock.timers.enable(['setTimeout']);
*
* setTimeout(fn, 9999);
* assert.strictEqual(fn.mock.callCount(), 0);
*
* // Advance in time
* context.mock.timers.tick(9999);
*
* assert.strictEqual(fn.mock.callCount(), 1);
* });
* ```
*
* Alternativelly, the `.tick` function can be called many times
*
* ```js
* import assert from 'node:assert';
* import { test } from 'node:test';
*
* test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {
* const fn = context.mock.fn();
* context.mock.timers.enable(['setTimeout']);
* const nineSecs = 9000;
* setTimeout(fn, nineSecs);
*
* const twoSeconds = 3000;
* context.mock.timers.tick(twoSeconds);
* context.mock.timers.tick(twoSeconds);
* context.mock.timers.tick(twoSeconds);
*
* assert.strictEqual(fn.mock.callCount(), 1);
* });
* ```
*
* ```js
* const assert = require('node:assert');
* const { test } = require('node:test');
*
* test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {
* const fn = context.mock.fn();
* context.mock.timers.enable(['setTimeout']);
* const nineSecs = 9000;
* setTimeout(fn, nineSecs);
*
* const twoSeconds = 3000;
* context.mock.timers.tick(twoSeconds);
* context.mock.timers.tick(twoSeconds);
* context.mock.timers.tick(twoSeconds);
*
* assert.strictEqual(fn.mock.callCount(), 1);
* });
* ```
* @since v20.4.0
*/
tick(milliseconds: number): void;
/**
* Triggers all pending mocked timers immediately.
*
* The example below triggers all pending timers immediately,
* causing them to execute without any delay.
*
* ```js
* import assert from 'node:assert';
* import { test } from 'node:test';
*
* test('runAll functions following the given order', (context) => {
* context.mock.timers.enable(['setTimeout']);
* const results = [];
* setTimeout(() => results.push(1), 9999);
*
* // Notice that if both timers have the same timeout,
* // the order of execution is guaranteed
* setTimeout(() => results.push(3), 8888);
* setTimeout(() => results.push(2), 8888);
*
* assert.deepStrictEqual(results, []);
*
* context.mock.timers.runAll();
*
* assert.deepStrictEqual(results, [3, 2, 1]);
* });
* ```
*
* ```js
* const assert = require('node:assert');
* const { test } = require('node:test');
*
* test('runAll functions following the given order', (context) => {
* context.mock.timers.enable(['setTimeout']);
* const results = [];
* setTimeout(() => results.push(1), 9999);
*
* // Notice that if both timers have the same timeout,
* // the order of execution is guaranteed
* setTimeout(() => results.push(3), 8888);
* setTimeout(() => results.push(2), 8888);
*
* assert.deepStrictEqual(results, []);
*
* context.mock.timers.runAll();
*
* assert.deepStrictEqual(results, [3, 2, 1]);
* });
* ```
*
* **Note:** The `runAll()` function is specifically designed for
* triggering timers in the context of timer mocking.
* It does not have any effect on real-time system
* clocks or actual timers outside of the mocking environment.
* @since v20.4.0
*/
runAll(): void;
}
export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock, skip, only, todo }; export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock, skip, only, todo };
} }
interface DiagnosticData {
/**
* The diagnostic message.
*/
message: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
}
interface TestFail {
/**
* Additional execution metadata.
*/
details: {
/**
* The duration of the test in milliseconds.
*/
duration: number;
/**
* The error thrown by the test.
*/
error: Error;
};
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The ordinal number of the test.
*/
testNumber: number;
/**
* Present if `context.todo` is called.
*/
todo?: string | boolean;
/**
* Present if `context.skip` is called.
*/
skip?: string | boolean;
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
}
interface TestPass {
/**
* Additional execution metadata.
*/
details: {
/**
* The duration of the test in milliseconds.
*/
duration: number;
};
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The ordinal number of the test.
*/
testNumber: number;
/**
* Present if `context.todo` is called.
*/
todo?: string | boolean;
/**
* Present if `context.skip` is called.
*/
skip?: string | boolean;
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
}
interface TestPlan {
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The number of subtests that have ran.
*/
count: number;
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
}
interface TestStart {
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
}
interface TestStderr {
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
/**
* The message written to `stderr`
*/
message: string;
}
interface TestStdout {
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
/**
* The message written to `stdout`
*/
message: string;
}
/**
* The `node:test/reporters` module exposes the builtin-reporters for `node:test`.
* To access it:
*
* ```js
* import test from 'node:test/reporters';
* ```
*
* This module is only available under the `node:` scheme. The following will not
* work:
*
* ```js
* import test from 'test/reporters';
* ```
* @since v19.9.0
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/test/reporters.js)
*/
declare module 'node:test/reporters' {
import { Transform } from 'node:stream';
type TestEvent =
| { type: 'test:diagnostic', data: DiagnosticData }
| { type: 'test:fail', data: TestFail }
| { type: 'test:pass', data: TestPass }
| { type: 'test:plan', data: TestPlan }
| { type: 'test:start', data: TestStart }
| { type: 'test:stderr', data: TestStderr }
| { type: 'test:stdout', data: TestStdout };
type TestEventGenerator = AsyncGenerator<TestEvent, void>;
/**
* The `dot` reporter outputs the test results in a compact format,
* where each passing test is represented by a `.`,
* and each failing test is represented by a `X`.
*/
function dot(source: TestEventGenerator): AsyncGenerator<'\n' | '.' | 'X', void>;
/**
* The `tap` reporter outputs the test results in the [TAP](https://testanything.org/) format.
*/
function tap(source: TestEventGenerator): AsyncGenerator<string, void>;
/**
* The `spec` reporter outputs the test results in a human-readable format.
*/
class Spec extends Transform {
constructor();
}
export { dot, tap, Spec as spec };
}

11
node_modules/@types/node/tls.d.ts generated vendored
View File

@ -728,6 +728,17 @@ declare module 'tls' {
} }
type SecureVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1'; type SecureVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
interface SecureContextOptions { interface SecureContextOptions {
/**
* If set, this will be called when a client opens a connection using the ALPN extension.
* One argument will be passed to the callback: an object containing `servername` and `protocols` fields,
* respectively containing the server name from the SNI extension (if any) and an array of
* ALPN protocol name strings. The callback must return either one of the strings listed in `protocols`,
* which will be returned to the client as the selected ALPN protocol, or `undefined`,
* to reject the connection with a fatal alert. If a string is returned that does not match one of
* the client's ALPN protocols, an error will be thrown.
* This option cannot be used with the `ALPNProtocols` option, and setting both options will throw an error.
*/
ALPNCallback?: ((arg: { servername: string; protocols: string[] }) => string | undefined) | undefined;
/** /**
* Optionally override the trusted CA certificates. Default is to trust * Optionally override the trusted CA certificates. Default is to trust
* the well-known CAs curated by Mozilla. Mozilla's CAs are completely * the well-known CAs curated by Mozilla. Mozilla's CAs are completely

View File

@ -299,6 +299,10 @@ declare module 'buffer' {
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
* ``` * ```
* *
* If `array` is an `Array`\-like object (that is, one with a `length` property of
* type `number`), it is treated as if it is an array, unless it is a `Buffer` or
* a `Uint8Array`. This means all other `TypedArray` variants get treated as an`Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use `Buffer.copyBytesFrom()`.
*
* A `TypeError` will be thrown if `array` is not an `Array` or another type * A `TypeError` will be thrown if `array` is not an `Array` or another type
* appropriate for `Buffer.from()` variants. * appropriate for `Buffer.from()` variants.
* *
@ -550,9 +554,8 @@ declare module 'buffer' {
* A `TypeError` will be thrown if `size` is not a number. * A `TypeError` will be thrown if `size` is not a number.
* *
* The `Buffer` module pre-allocates an internal `Buffer` instance of * The `Buffer` module pre-allocates an internal `Buffer` instance of
* size `Buffer.poolSize` that is used as a pool for the fast allocation of new`Buffer` instances created using `Buffer.allocUnsafe()`,`Buffer.from(array)`, `Buffer.concat()`, and the * size `Buffer.poolSize` that is used as a pool for the fast allocation of new`Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
* deprecated`new Buffer(size)` constructor only when `size` is less than or equal * and `Buffer.concat()` only when `size` is less than or equal to`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
* to `Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
* *
* Use of this pre-allocated internal memory pool is a key difference between * Use of this pre-allocated internal memory pool is a key difference between
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`. * calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.

View File

@ -56,6 +56,7 @@ declare module 'cluster' {
import * as child from 'node:child_process'; import * as child from 'node:child_process';
import EventEmitter = require('node:events'); import EventEmitter = require('node:events');
import * as net from 'node:net'; import * as net from 'node:net';
type SerializationType = 'json' | 'advanced';
export interface ClusterSettings { export interface ClusterSettings {
execArgv?: string[] | undefined; // default: process.execArgv execArgv?: string[] | undefined; // default: process.execArgv
exec?: string | undefined; exec?: string | undefined;
@ -65,6 +66,9 @@ declare module 'cluster' {
uid?: number | undefined; uid?: number | undefined;
gid?: number | undefined; gid?: number | undefined;
inspectPort?: number | (() => number) | undefined; inspectPort?: number | (() => number) | undefined;
serialization?: SerializationType | undefined;
cwd?: string | undefined;
windowsHide?: boolean | undefined;
} }
export interface Address { export interface Address {
address: string; address: string;

View File

@ -21,14 +21,14 @@ declare module 'crypto' {
import { PeerCertificate } from 'node:tls'; import { PeerCertificate } from 'node:tls';
/** /**
* SPKAC is a Certificate Signing Request mechanism originally implemented by * SPKAC is a Certificate Signing Request mechanism originally implemented by
* Netscape and was specified formally as part of [HTML5's `keygen` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/keygen). * Netscape and was specified formally as part of HTML5's `keygen` element.
* *
* `<keygen>` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects * `<keygen>` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects
* should not use this element anymore. * should not use this element anymore.
* *
* The `node:crypto` module provides the `Certificate` class for working with SPKAC * The `node:crypto` module provides the `Certificate` class for working with SPKAC
* data. The most common usage is handling output generated by the HTML5`<keygen>` element. Node.js uses [OpenSSL's SPKAC * data. The most common usage is handling output generated by the HTML5`<keygen>` element. Node.js uses [OpenSSL's SPKAC
* implementation](https://www.openssl.org/docs/man1.1.0/apps/openssl-spkac.html) internally. * implementation](https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html) internally.
* @since v0.11.8 * @since v0.11.8
*/ */
class Certificate { class Certificate {
@ -223,7 +223,9 @@ declare module 'crypto' {
* display the available digest algorithms. * display the available digest algorithms.
* *
* The `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is * The `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is
* a `KeyObject`, its type must be `secret`. * a `KeyObject`, its type must be `secret`. If it is a string, please consider `caveats when using strings as inputs to cryptographic APIs`. If it was
* obtained from a cryptographically secure source of entropy, such as {@link randomBytes} or {@link generateKey}, its length should not
* exceed the block size of `algorithm` (e.g., 512 bits for SHA-256).
* *
* Example: generating the sha256 HMAC of a file * Example: generating the sha256 HMAC of a file
* *
@ -683,13 +685,13 @@ declare module 'crypto' {
* **GCM, or CCM).** * **GCM, or CCM).**
* *
* The implementation of `crypto.createCipher()` derives keys using the OpenSSL * The implementation of `crypto.createCipher()` derives keys using the OpenSSL
* function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
* iteration, and no salt. The lack of salt allows dictionary attacks as the same * iteration, and no salt. The lack of salt allows dictionary attacks as the same
* password always creates the same key. The low iteration count and * password always creates the same key. The low iteration count and
* non-cryptographically secure hash algorithm allow passwords to be tested very * non-cryptographically secure hash algorithm allow passwords to be tested very
* rapidly. * rapidly.
* *
* In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) it is recommended that * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that
* developers derive a key and IV on * developers derive a key and IV on
* their own using {@link scrypt} and to use {@link createCipheriv} to create the `Cipher` object. Users should not use ciphers with counter mode * their own using {@link scrypt} and to use {@link createCipheriv} to create the `Cipher` object. Users should not use ciphers with counter mode
* (e.g. CTR, GCM, or CCM) in `crypto.createCipher()`. A warning is emitted when * (e.g. CTR, GCM, or CCM) in `crypto.createCipher()`. A warning is emitted when
@ -944,13 +946,13 @@ declare module 'crypto' {
* **GCM, or CCM).** * **GCM, or CCM).**
* *
* The implementation of `crypto.createDecipher()` derives keys using the OpenSSL * The implementation of `crypto.createDecipher()` derives keys using the OpenSSL
* function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
* iteration, and no salt. The lack of salt allows dictionary attacks as the same * iteration, and no salt. The lack of salt allows dictionary attacks as the same
* password always creates the same key. The low iteration count and * password always creates the same key. The low iteration count and
* non-cryptographically secure hash algorithm allow passwords to be tested very * non-cryptographically secure hash algorithm allow passwords to be tested very
* rapidly. * rapidly.
* *
* In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) it is recommended that * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that
* developers derive a key and IV on * developers derive a key and IV on
* their own using {@link scrypt} and to use {@link createDecipheriv} to create the `Decipher` object. * their own using {@link scrypt} and to use {@link createDecipheriv} to create the `Decipher` object.
* @since v0.1.94 * @since v0.1.94
@ -1195,11 +1197,14 @@ declare module 'crypto' {
* generateKey, * generateKey,
* } = await import('node:crypto'); * } = await import('node:crypto');
* *
* generateKey('hmac', { length: 64 }, (err, key) => { * generateKey('hmac', { length: 512 }, (err, key) => {
* if (err) throw err; * if (err) throw err;
* console.log(key.export().toString('hex')); // 46e..........620 * console.log(key.export().toString('hex')); // 46e..........620
* }); * });
* ``` * ```
*
* The size of a generated HMAC key should not exceed the block size of the
* underlying hash function. See {@link createHmac} for more information.
* @since v15.0.0 * @since v15.0.0
* @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`. * @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`.
*/ */
@ -1218,9 +1223,12 @@ declare module 'crypto' {
* generateKeySync, * generateKeySync,
* } = await import('node:crypto'); * } = await import('node:crypto');
* *
* const key = generateKeySync('hmac', { length: 64 }); * const key = generateKeySync('hmac', { length: 512 });
* console.log(key.export().toString('hex')); // e89..........41e * console.log(key.export().toString('hex')); // e89..........41e
* ``` * ```
*
* The size of a generated HMAC key should not exceed the block size of the
* underlying hash function. See {@link createHmac} for more information.
* @since v15.0.0 * @since v15.0.0
* @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`. * @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`.
*/ */
@ -1508,10 +1516,15 @@ declare module 'crypto' {
class DiffieHellman { class DiffieHellman {
private constructor(); private constructor();
/** /**
* Generates private and public Diffie-Hellman key values, and returns * Generates private and public Diffie-Hellman key values unless they have been
* generated or computed already, and returns
* the public key in the specified `encoding`. This key should be * the public key in the specified `encoding`. This key should be
* transferred to the other party. * transferred to the other party.
* If `encoding` is provided a string is returned; otherwise a `Buffer` is returned. * If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.
*
* This function is a thin wrapper around [`DH_generate_key()`](https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html). In particular,
* once a private key has been generated or set, calling this function only updates
* the public key but does not generate a new private key.
* @since v0.5.0 * @since v0.5.0
* @param encoding The `encoding` of the return value. * @param encoding The `encoding` of the return value.
*/ */
@ -1583,6 +1596,9 @@ declare module 'crypto' {
* Sets the Diffie-Hellman private key. If the `encoding` argument is provided,`privateKey` is expected * Sets the Diffie-Hellman private key. If the `encoding` argument is provided,`privateKey` is expected
* to be a string. If no `encoding` is provided, `privateKey` is expected * to be a string. If no `encoding` is provided, `privateKey` is expected
* to be a `Buffer`, `TypedArray`, or `DataView`. * to be a `Buffer`, `TypedArray`, or `DataView`.
*
* This function does not automatically compute the associated public key. Either `diffieHellman.setPublicKey()` or `diffieHellman.generateKeys()` can be
* used to manually provide the public key or to automatically derive it.
* @since v0.5.0 * @since v0.5.0
* @param encoding The `encoding` of the `privateKey` string. * @param encoding The `encoding` of the `privateKey` string.
*/ */

View File

@ -1632,18 +1632,19 @@ declare module 'fs' {
* *
* The callback is given a possible exception and, if `recursive` is `true`, the * The callback is given a possible exception and, if `recursive` is `true`, the
* first directory path created, `(err[, path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was * first directory path created, `(err[, path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was
* created. * created (for instance, if it was previously created).
* *
* The optional `options` argument can be an integer specifying `mode` (permission * The optional `options` argument can be an integer specifying `mode` (permission
* and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fs.mkdir()` when `path` is a directory that * and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fs.mkdir()` when `path` is a directory that
* exists results in an error only * exists results in an error only
* when `recursive` is false. * when `recursive` is false. If `recursive` is false and the directory exists,
* an `EEXIST` error occurs.
* *
* ```js * ```js
* import { mkdir } from 'node:fs'; * import { mkdir } from 'node:fs';
* *
* // Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist. * // Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist.
* mkdir('/tmp/a/apple', { recursive: true }, (err) => { * mkdir('./tmp/a/apple', { recursive: true }, (err) => {
* if (err) throw err; * if (err) throw err;
* }); * });
* ``` * ```
@ -3088,7 +3089,7 @@ declare module 'fs' {
recursive?: boolean | undefined; recursive?: boolean | undefined;
} }
export type WatchEventType = 'rename' | 'change'; export type WatchEventType = 'rename' | 'change';
export type WatchListener<T> = (event: WatchEventType, filename: T) => void; export type WatchListener<T> = (event: WatchEventType, filename: T | null) => void;
export type StatsListener = (curr: Stats, prev: Stats) => void; export type StatsListener = (curr: Stats, prev: Stats) => void;
export type BigIntStatsListener = (curr: BigIntStats, prev: BigIntStats) => void; export type BigIntStatsListener = (curr: BigIntStats, prev: BigIntStats) => void;
/** /**

View File

@ -43,7 +43,7 @@ declare module 'fs/promises' {
import { Interface as ReadlineInterface } from 'node:readline'; import { Interface as ReadlineInterface } from 'node:readline';
interface FileChangeInfo<T extends string | Buffer> { interface FileChangeInfo<T extends string | Buffer> {
eventType: WatchEventType; eventType: WatchEventType;
filename: T; filename: T | null;
} }
interface FlagAndOpenMode { interface FlagAndOpenMode {
mode?: Mode | undefined; mode?: Mode | undefined;

View File

@ -73,11 +73,24 @@ declare module 'module' {
readonly payload: SourceMapPayload; readonly payload: SourceMapPayload;
constructor(payload: SourceMapPayload); constructor(payload: SourceMapPayload);
/** /**
* Given a line number and column number in the generated source file, returns * Given a line offset and column offset in the generated source
* an object representing the position in the original file. The object returned * file, returns an object representing the SourceMap range in the
* consists of the following keys: * original file if found, or an empty object if not.
*
* The object returned contains the following keys:
*
* The returned value represents the raw range as it appears in the
* SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and
* column numbers as they appear in Error messages and CallSite
* objects.
*
* To get the corresponding 1-indexed line and column numbers from a
* lineNumber and columnNumber as they are reported by Error stacks
* and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)`
* @param lineOffset The zero-indexed line number offset in the generated source
* @param columnOffset The zero-indexed column number offset in the generated source
*/ */
findEntry(line: number, column: number): SourceMapping; findEntry(lineOffset: number, columnOffset: number): SourceMapping;
} }
} }
interface Module extends NodeModule {} interface Module extends NodeModule {}

View File

@ -310,12 +310,14 @@ declare module 'net' {
*/ */
readonly remoteAddress?: string | undefined; readonly remoteAddress?: string | undefined;
/** /**
* The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. * The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. Value may be `undefined` if
* the socket is destroyed (for example, if the client disconnected).
* @since v0.11.14 * @since v0.11.14
*/ */
readonly remoteFamily?: string | undefined; readonly remoteFamily?: string | undefined;
/** /**
* The numeric representation of the remote port. For example, `80` or `21`. * The numeric representation of the remote port. For example, `80` or `21`. Value may be `undefined` if
* the socket is destroyed (for example, if the client disconnected).
* @since v0.5.10 * @since v0.5.10
*/ */
readonly remotePort?: number | undefined; readonly remotePort?: number | undefined;
@ -744,8 +746,8 @@ declare module 'net' {
* *
* Test this by using `telnet`: * Test this by using `telnet`:
* *
* ```console * ```bash
* $ telnet localhost 8124 * telnet localhost 8124
* ``` * ```
* *
* To listen on the socket `/tmp/echo.sock`: * To listen on the socket `/tmp/echo.sock`:
@ -758,8 +760,8 @@ declare module 'net' {
* *
* Use `nc` to connect to a Unix domain socket server: * Use `nc` to connect to a Unix domain socket server:
* *
* ```console * ```bash
* $ nc -U /tmp/echo.sock * nc -U /tmp/echo.sock
* ``` * ```
* @since v0.5.0 * @since v0.5.0
* @param connectionListener Automatically set as a listener for the {@link 'connection'} event. * @param connectionListener Automatically set as a listener for the {@link 'connection'} event.

View File

@ -307,8 +307,8 @@ declare module 'process' {
* *
* Launching the Node.js process as: * Launching the Node.js process as:
* *
* ```console * ```bash
* $ node process-args.js one two=three four * node process-args.js one two=three four
* ``` * ```
* *
* Would generate the output: * Would generate the output:
@ -344,8 +344,8 @@ declare module 'process' {
* the script name. These options are useful in order to spawn child processes with * the script name. These options are useful in order to spawn child processes with
* the same execution environment as the parent. * the same execution environment as the parent.
* *
* ```console * ```bash
* $ node --harmony script.js --version * node --harmony script.js --version
* ``` * ```
* *
* Results in `process.execArgv`: * Results in `process.execArgv`:
@ -492,8 +492,8 @@ declare module 'process' {
* to other `Worker` threads. * to other `Worker` threads.
* In other words, the following example would not work: * In other words, the following example would not work:
* *
* ```console * ```bash
* $ node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo * node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo
* ``` * ```
* *
* While the following will: * While the following will:
@ -898,21 +898,30 @@ declare module 'process' {
* Will generate an object similar to: * Will generate an object similar to:
* *
* ```console * ```console
* { node: '11.13.0', * { node: '20.2.0',
* v8: '7.0.276.38-node.18', * acorn: '8.8.2',
* uv: '1.27.0', * ada: '2.4.0',
* zlib: '1.2.11', * ares: '1.19.0',
* brotli: '1.0.7', * base64: '0.5.0',
* ares: '1.15.0', * brotli: '1.0.9',
* modules: '67', * cjs_module_lexer: '1.2.2',
* nghttp2: '1.34.0', * cldr: '43.0',
* napi: '4', * icu: '73.1',
* llhttp: '1.1.1', * llhttp: '8.1.0',
* openssl: '1.1.1b', * modules: '115',
* cldr: '34.0', * napi: '8',
* icu: '63.1', * nghttp2: '1.52.0',
* tz: '2018e', * nghttp3: '0.7.0',
* unicode: '11.0' } * ngtcp2: '0.8.1',
* openssl: '3.0.8+quic',
* simdutf: '3.2.9',
* tz: '2023c',
* undici: '5.22.0',
* unicode: '15.0',
* uv: '1.44.2',
* uvwasi: '0.0.16',
* v8: '11.3.244.8-node.9',
* zlib: '1.2.13' }
* ``` * ```
* @since v0.2.0 * @since v0.2.0
*/ */

View File

@ -159,7 +159,7 @@ declare module 'node:test' {
* @param [name='The name'] The name of the suite, which is displayed when reporting test results. * @param [name='The name'] The name of the suite, which is displayed when reporting test results.
* @param options Configuration options for the suite. supports the same options as `test([name][, options][, fn])`. * @param options Configuration options for the suite. supports the same options as `test([name][, options][, fn])`.
* @param [fn='A no-op function'] The function under suite declaring all subtests and subsuites. The first argument to this function is a {@link SuiteContext} object. * @param [fn='A no-op function'] The function under suite declaring all subtests and subsuites. The first argument to this function is a {@link SuiteContext} object.
* @return `undefined`. * @return Immediately fulfilled with `undefined`.
*/ */
function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void; function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void;
function describe(name?: string, fn?: SuiteFn): void; function describe(name?: string, fn?: SuiteFn): void;
@ -307,134 +307,50 @@ declare module 'node:test' {
addListener(event: 'test:pass', listener: (data: TestPass) => void): this; addListener(event: 'test:pass', listener: (data: TestPass) => void): this;
addListener(event: 'test:plan', listener: (data: TestPlan) => void): this; addListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
addListener(event: 'test:start', listener: (data: TestStart) => void): this; addListener(event: 'test:start', listener: (data: TestStart) => void): this;
addListener(event: 'test:stderr', listener: (data: TestStderr) => void): this;
addListener(event: 'test:stdout', listener: (data: TestStdout) => void): this;
addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: string, listener: (...args: any[]) => void): this;
emit(event: 'test:diagnostic', data: DiagnosticData): boolean; emit(event: 'test:diagnostic', data: DiagnosticData): boolean;
emit(event: 'test:fail', data: TestFail): boolean; emit(event: 'test:fail', data: TestFail): boolean;
emit(event: 'test:pass', data: TestPass): boolean; emit(event: 'test:pass', data: TestPass): boolean;
emit(event: 'test:plan', data: TestPlan): boolean; emit(event: 'test:plan', data: TestPlan): boolean;
emit(event: 'test:start', data: TestStart): boolean; emit(event: 'test:start', data: TestStart): boolean;
emit(event: 'test:stderr', data: TestStderr): boolean;
emit(event: 'test:stdout', data: TestStdout): boolean;
emit(event: string | symbol, ...args: any[]): boolean; emit(event: string | symbol, ...args: any[]): boolean;
on(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; on(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
on(event: 'test:fail', listener: (data: TestFail) => void): this; on(event: 'test:fail', listener: (data: TestFail) => void): this;
on(event: 'test:pass', listener: (data: TestPass) => void): this; on(event: 'test:pass', listener: (data: TestPass) => void): this;
on(event: 'test:plan', listener: (data: TestPlan) => void): this; on(event: 'test:plan', listener: (data: TestPlan) => void): this;
on(event: 'test:start', listener: (data: TestStart) => void): this; on(event: 'test:start', listener: (data: TestStart) => void): this;
on(event: 'test:stderr', listener: (data: TestStderr) => void): this;
on(event: 'test:stdout', listener: (data: TestStdout) => void): this;
on(event: string, listener: (...args: any[]) => void): this; on(event: string, listener: (...args: any[]) => void): this;
once(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; once(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
once(event: 'test:fail', listener: (data: TestFail) => void): this; once(event: 'test:fail', listener: (data: TestFail) => void): this;
once(event: 'test:pass', listener: (data: TestPass) => void): this; once(event: 'test:pass', listener: (data: TestPass) => void): this;
once(event: 'test:plan', listener: (data: TestPlan) => void): this; once(event: 'test:plan', listener: (data: TestPlan) => void): this;
once(event: 'test:start', listener: (data: TestStart) => void): this; once(event: 'test:start', listener: (data: TestStart) => void): this;
once(event: 'test:stderr', listener: (data: TestStderr) => void): this;
once(event: 'test:stdout', listener: (data: TestStdout) => void): this;
once(event: string, listener: (...args: any[]) => void): this; once(event: string, listener: (...args: any[]) => void): this;
prependListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; prependListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
prependListener(event: 'test:fail', listener: (data: TestFail) => void): this; prependListener(event: 'test:fail', listener: (data: TestFail) => void): this;
prependListener(event: 'test:pass', listener: (data: TestPass) => void): this; prependListener(event: 'test:pass', listener: (data: TestPass) => void): this;
prependListener(event: 'test:plan', listener: (data: TestPlan) => void): this; prependListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
prependListener(event: 'test:start', listener: (data: TestStart) => void): this; prependListener(event: 'test:start', listener: (data: TestStart) => void): this;
prependListener(event: 'test:stderr', listener: (data: TestStderr) => void): this;
prependListener(event: 'test:stdout', listener: (data: TestStdout) => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this; prependOnceListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this; prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this;
prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this; prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this;
prependOnceListener(event: 'test:plan', listener: (data: TestPlan) => void): this; prependOnceListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
prependOnceListener(event: 'test:start', listener: (data: TestStart) => void): this; prependOnceListener(event: 'test:start', listener: (data: TestStart) => void): this;
prependOnceListener(event: 'test:stderr', listener: (data: TestStderr) => void): this;
prependOnceListener(event: 'test:stdout', listener: (data: TestStdout) => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: string, listener: (...args: any[]) => void): this;
} }
interface DiagnosticData {
/**
* The diagnostic message.
*/
message: string;
/**
* The nesting level of the test.
*/
nesting: number;
}
interface TestFail {
/**
* Additional execution metadata.
*/
details: {
/**
* The duration of the test in milliseconds.
*/
duration: number;
/**
* The error thrown by the test.
*/
error: Error;
};
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The ordinal number of the test.
*/
testNumber: number;
/**
* Present if `context.todo` is called.
*/
todo?: string | boolean;
/**
* Present if `context.skip` is called.
*/
skip?: string | boolean;
}
interface TestPass {
/**
* Additional execution metadata.
*/
details: {
/**
* The duration of the test in milliseconds.
*/
duration: number;
};
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The ordinal number of the test.
*/
testNumber: number;
/**
* Present if `context.todo` is called.
*/
todo?: string | boolean;
/**
* Present if `context.skip` is called.
*/
skip?: string | boolean;
}
interface TestPlan {
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The number of subtests that have ran.
*/
count: number;
}
interface TestStart {
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
}
/** /**
* An instance of `TestContext` is passed to each test function in order to * An instance of `TestContext` is passed to each test function in order to
* interact with the test runner. However, the `TestContext` constructor is not * interact with the test runner. However, the `TestContext` constructor is not
@ -905,6 +821,7 @@ declare module 'node:test' {
* @since v19.1.0, v18.13.0 * @since v19.1.0, v18.13.0
*/ */
restoreAll(): void; restoreAll(): void;
timers: MockTimers;
} }
const mock: MockTracker; const mock: MockTracker;
interface MockFunctionCall< interface MockFunctionCall<
@ -1048,5 +965,401 @@ declare module 'node:test' {
*/ */
restore(): void; restore(): void;
} }
type Timer = 'setInterval' | 'clearInterval' | 'setTimeout' | 'clearTimeout';
/**
* Mocking timers is a technique commonly used in software testing to simulate and
* control the behavior of timers, such as `setInterval` and `setTimeout`,
* without actually waiting for the specified time intervals.
*
* The `MockTracker` provides a top-level `timers` export
* which is a `MockTimers` instance.
* @since v20.4.0
* @experimental
*/
class MockTimers {
/**
* Enables timer mocking for the specified timers.
*
* **Note:** When you enable mocking for a specific timer, its associated
* clear function will also be implicitly mocked.
*
* Example usage:
*
* ```js
* import { mock } from 'node:test';
* mock.timers.enable(['setInterval']);
* ```
*
* ```js
* const { mock } = require('node:test');
* mock.timers.enable(['setInterval']);
* ```
*
* 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.
*
* Alternatively, if you call `mock.timers.enable()` without any parameters:
*
* 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.
* @since v20.4.0
*/
enable(timers?: Timer[]): void;
/**
* This function restores the default behavior of all mocks that were previously
* created by this `MockTimers` instance and disassociates the mocks
* from the `MockTracker` instance.
*
* **Note:** After each test completes, this function is called on
* the test context's `MockTracker`.
*
* ```js
* import { mock } from 'node:test';
* mock.timers.reset();
* ```
*
* ```js
* const { mock } = require('node:test');
* mock.timers.reset();
* ```
* @since v20.4.0
*/
reset(): void;
/**
* Advances time for all mocked timers.
*
* **Note:** This diverges from how `setTimeout` in Node.js behaves and accepts
* only positive numbers. In Node.js, `setTimeout` with negative numbers is
* only supported for web compatibility reasons.
*
* The following example mocks a `setTimeout` function and
* by using `.tick` advances in
* time triggering all pending timers.
*
* ```js
* import assert from 'node:assert';
* import { test } from 'node:test';
*
* test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {
* const fn = context.mock.fn();
*
* context.mock.timers.enable(['setTimeout']);
*
* setTimeout(fn, 9999);
*
* assert.strictEqual(fn.mock.callCount(), 0);
*
* // Advance in time
* context.mock.timers.tick(9999);
*
* assert.strictEqual(fn.mock.callCount(), 1);
* });
* ```
*
* ```js
* const assert = require('node:assert');
* const { test } = require('node:test');
*
* test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {
* const fn = context.mock.fn();
* context.mock.timers.enable(['setTimeout']);
*
* setTimeout(fn, 9999);
* assert.strictEqual(fn.mock.callCount(), 0);
*
* // Advance in time
* context.mock.timers.tick(9999);
*
* assert.strictEqual(fn.mock.callCount(), 1);
* });
* ```
*
* Alternativelly, the `.tick` function can be called many times
*
* ```js
* import assert from 'node:assert';
* import { test } from 'node:test';
*
* test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {
* const fn = context.mock.fn();
* context.mock.timers.enable(['setTimeout']);
* const nineSecs = 9000;
* setTimeout(fn, nineSecs);
*
* const twoSeconds = 3000;
* context.mock.timers.tick(twoSeconds);
* context.mock.timers.tick(twoSeconds);
* context.mock.timers.tick(twoSeconds);
*
* assert.strictEqual(fn.mock.callCount(), 1);
* });
* ```
*
* ```js
* const assert = require('node:assert');
* const { test } = require('node:test');
*
* test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {
* const fn = context.mock.fn();
* context.mock.timers.enable(['setTimeout']);
* const nineSecs = 9000;
* setTimeout(fn, nineSecs);
*
* const twoSeconds = 3000;
* context.mock.timers.tick(twoSeconds);
* context.mock.timers.tick(twoSeconds);
* context.mock.timers.tick(twoSeconds);
*
* assert.strictEqual(fn.mock.callCount(), 1);
* });
* ```
* @since v20.4.0
*/
tick(milliseconds: number): void;
/**
* Triggers all pending mocked timers immediately.
*
* The example below triggers all pending timers immediately,
* causing them to execute without any delay.
*
* ```js
* import assert from 'node:assert';
* import { test } from 'node:test';
*
* test('runAll functions following the given order', (context) => {
* context.mock.timers.enable(['setTimeout']);
* const results = [];
* setTimeout(() => results.push(1), 9999);
*
* // Notice that if both timers have the same timeout,
* // the order of execution is guaranteed
* setTimeout(() => results.push(3), 8888);
* setTimeout(() => results.push(2), 8888);
*
* assert.deepStrictEqual(results, []);
*
* context.mock.timers.runAll();
*
* assert.deepStrictEqual(results, [3, 2, 1]);
* });
* ```
*
* ```js
* const assert = require('node:assert');
* const { test } = require('node:test');
*
* test('runAll functions following the given order', (context) => {
* context.mock.timers.enable(['setTimeout']);
* const results = [];
* setTimeout(() => results.push(1), 9999);
*
* // Notice that if both timers have the same timeout,
* // the order of execution is guaranteed
* setTimeout(() => results.push(3), 8888);
* setTimeout(() => results.push(2), 8888);
*
* assert.deepStrictEqual(results, []);
*
* context.mock.timers.runAll();
*
* assert.deepStrictEqual(results, [3, 2, 1]);
* });
* ```
*
* **Note:** The `runAll()` function is specifically designed for
* triggering timers in the context of timer mocking.
* It does not have any effect on real-time system
* clocks or actual timers outside of the mocking environment.
* @since v20.4.0
*/
runAll(): void;
}
export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock, skip, only, todo }; export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock, skip, only, todo };
} }
interface DiagnosticData {
/**
* The diagnostic message.
*/
message: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
}
interface TestFail {
/**
* Additional execution metadata.
*/
details: {
/**
* The duration of the test in milliseconds.
*/
duration: number;
/**
* The error thrown by the test.
*/
error: Error;
};
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The ordinal number of the test.
*/
testNumber: number;
/**
* Present if `context.todo` is called.
*/
todo?: string | boolean;
/**
* Present if `context.skip` is called.
*/
skip?: string | boolean;
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
}
interface TestPass {
/**
* Additional execution metadata.
*/
details: {
/**
* The duration of the test in milliseconds.
*/
duration: number;
};
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The ordinal number of the test.
*/
testNumber: number;
/**
* Present if `context.todo` is called.
*/
todo?: string | boolean;
/**
* Present if `context.skip` is called.
*/
skip?: string | boolean;
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
}
interface TestPlan {
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The number of subtests that have ran.
*/
count: number;
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
}
interface TestStart {
/**
* The test name.
*/
name: string;
/**
* The nesting level of the test.
*/
nesting: number;
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
}
interface TestStderr {
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
/**
* The message written to `stderr`
*/
message: string;
}
interface TestStdout {
/**
* The path of the test file, undefined if test is not ran through a file.
*/
file?: string;
/**
* The message written to `stdout`
*/
message: string;
}
/**
* The `node:test/reporters` module exposes the builtin-reporters for `node:test`.
* To access it:
*
* ```js
* import test from 'node:test/reporters';
* ```
*
* This module is only available under the `node:` scheme. The following will not
* work:
*
* ```js
* import test from 'test/reporters';
* ```
* @since v19.9.0
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/test/reporters.js)
*/
declare module 'node:test/reporters' {
import { Transform } from 'node:stream';
type TestEvent =
| { type: 'test:diagnostic', data: DiagnosticData }
| { type: 'test:fail', data: TestFail }
| { type: 'test:pass', data: TestPass }
| { type: 'test:plan', data: TestPlan }
| { type: 'test:start', data: TestStart }
| { type: 'test:stderr', data: TestStderr }
| { type: 'test:stdout', data: TestStdout };
type TestEventGenerator = AsyncGenerator<TestEvent, void>;
/**
* The `dot` reporter outputs the test results in a compact format,
* where each passing test is represented by a `.`,
* and each failing test is represented by a `X`.
*/
function dot(source: TestEventGenerator): AsyncGenerator<'\n' | '.' | 'X', void>;
/**
* The `tap` reporter outputs the test results in the [TAP](https://testanything.org/) format.
*/
function tap(source: TestEventGenerator): AsyncGenerator<string, void>;
/**
* The `spec` reporter outputs the test results in a human-readable format.
*/
class Spec extends Transform {
constructor();
}
export { dot, tap, Spec as spec };
}

View File

@ -728,6 +728,17 @@ declare module 'tls' {
} }
type SecureVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1'; type SecureVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
interface SecureContextOptions { interface SecureContextOptions {
/**
* If set, this will be called when a client opens a connection using the ALPN extension.
* One argument will be passed to the callback: an object containing `servername` and `protocols` fields,
* respectively containing the server name from the SNI extension (if any) and an array of
* ALPN protocol name strings. The callback must return either one of the strings listed in `protocols`,
* which will be returned to the client as the selected ALPN protocol, or `undefined`,
* to reject the connection with a fatal alert. If a string is returned that does not match one of
* the client's ALPN protocols, an error will be thrown.
* This option cannot be used with the `ALPNProtocols` option, and setting both options will throw an error.
*/
ALPNCallback?: ((arg: { servername: string; protocols: string[] }) => string | undefined) | undefined;
/** /**
* Optionally override the trusted CA certificates. Default is to trust * Optionally override the trusted CA certificates. Default is to trust
* the well-known CAs curated by Mozilla. Mozilla's CAs are completely * the well-known CAs curated by Mozilla. Mozilla's CAs are completely

View File

@ -42,7 +42,10 @@ declare module 'tty' {
constructor(fd: number, options?: net.SocketConstructorOpts); constructor(fd: number, options?: net.SocketConstructorOpts);
/** /**
* A `boolean` that is `true` if the TTY is currently configured to operate as a * A `boolean` that is `true` if the TTY is currently configured to operate as a
* raw device. Defaults to `false`. * raw device.
*
* This flag is always `false` when a process starts, even if the terminal is
* operating in raw mode. Its value will change with subsequent calls to`setRawMode`.
* @since v0.7.7 * @since v0.7.7
*/ */
isRaw: boolean; isRaw: boolean;

View File

@ -1460,32 +1460,72 @@ declare module 'util' {
/** /**
* Gets and sets the type portion of the MIME. * Gets and sets the type portion of the MIME.
*
* ```js
* import { MIMEType } from 'node:util';
*
* const myMIME = new MIMEType('text/javascript');
* console.log(myMIME.type);
* // Prints: text
* myMIME.type = 'application';
* console.log(myMIME.type);
* // Prints: application
* console.log(String(myMIME));
* // Prints: application/javascript
* ```
*/ */
type: string; type: string;
/** /**
* Gets and sets the subtype portion of the MIME. * Gets and sets the subtype portion of the MIME.
*
* ```js
* import { MIMEType } from 'node:util';
*
* const myMIME = new MIMEType('text/ecmascript');
* console.log(myMIME.subtype);
* // Prints: ecmascript
* myMIME.subtype = 'javascript';
* console.log(myMIME.subtype);
* // Prints: javascript
* console.log(String(myMIME));
* // Prints: text/javascript
* ```
*/ */
subtype: string; subtype: string;
/** /**
* Gets the essence of the MIME. * Gets the essence of the MIME. This property is read only.
*
* Use `mime.type` or `mime.subtype` to alter the MIME. * Use `mime.type` or `mime.subtype` to alter the MIME.
*
* ```js
* import { MIMEType } from 'node:util';
*
* const myMIME = new MIMEType('text/javascript;key=value');
* console.log(myMIME.essence);
* // Prints: text/javascript
* myMIME.type = 'application';
* console.log(myMIME.essence);
* // Prints: application/javascript
* console.log(String(myMIME));
* // Prints: application/javascript;key=value
* ```
*/ */
readonly essence: string; readonly essence: string;
/** /**
* Gets the `MIMEParams` object representing the parameters of the MIME. * Gets the `MIMEParams` object representing the
* parameters of the MIME. This property is read-only. See `MIMEParams` documentation for details.
*/ */
readonly params: MIMEParams; readonly params: MIMEParams;
/** /**
* Returns the serialized MIME. * The `toString()` method on the `MIMEType` object returns the serialized MIME.
* *
* Because of the need for standard compliance, this method * Because of the need for standard compliance, this method does not allow users
* does not allow users to customize the serialization process of the MIME. * to customize the serialization process of the MIME.
*/ */
toString(): string; toString(): string;
} }
/** /**
* @since v18.13.0 * The `MIMEParams` API provides read and write access to the parameters of a`MIMEType`.
* @since v19.1.0, v18.13.0
*/ */
export class MIMEParams { export class MIMEParams {
/** /**
@ -1494,11 +1534,14 @@ declare module 'util' {
delete(name: string): void; delete(name: string): void;
/** /**
* Returns an iterator over each of the name-value pairs in the parameters. * Returns an iterator over each of the name-value pairs in the parameters.
* Each item of the iterator is a JavaScript `Array`. The first item of the array
* is the `name`, the second item of the array is the `value`.
*/ */
entries(): IterableIterator<[string, string]>; entries(): IterableIterator<[string, string]>;
/** /**
* Returns the value of the first name-value pair whose name is `name`. * Returns the value of the first name-value pair whose name is `name`. If there
* If there are no such pairs, `null` is returned. * are no such pairs, `null` is returned.
* @return or `null` if there is no name-value pair with the given `name`.
*/ */
get(name: string): string | null; get(name: string): string | null;
/** /**
@ -1507,12 +1550,33 @@ declare module 'util' {
has(name: string): boolean; has(name: string): boolean;
/** /**
* Returns an iterator over the names of each name-value pair. * Returns an iterator over the names of each name-value pair.
*
* ```js
* import { MIMEType } from 'node:util';
*
* const { params } = new MIMEType('text/plain;foo=0;bar=1');
* for (const name of params.keys()) {
* console.log(name);
* }
* // Prints:
* // foo
* // bar
* ```
*/ */
keys(): IterableIterator<string>; keys(): IterableIterator<string>;
/** /**
* Sets the value in the `MIMEParams` object associated with `name` to `value`. * Sets the value in the `MIMEParams` object associated with `name` to`value`. If there are any pre-existing name-value pairs whose names are `name`,
* If there are any pre-existing name-value pairs whose names are `name`,
* set the first such pair's value to `value`. * set the first such pair's value to `value`.
*
* ```js
* import { MIMEType } from 'node:util';
*
* const { params } = new MIMEType('text/plain;foo=0;bar=1');
* params.set('foo', 'def');
* params.set('baz', 'xyz');
* console.log(params.toString());
* // Prints: foo=def&#x26;bar=1&#x26;baz=xyz
* ```
*/ */
set(name: string, value: string): void; set(name: string, value: string): void;
/** /**

View File

@ -58,8 +58,8 @@
* *
* Use [wabt](https://github.com/WebAssembly/wabt) to compile `.wat` to `.wasm` * Use [wabt](https://github.com/WebAssembly/wabt) to compile `.wat` to `.wasm`
* *
* ```console * ```bash
* $ wat2wasm demo.wat * wat2wasm demo.wat
* ``` * ```
* @experimental * @experimental
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/wasi.js) * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/wasi.js)

5
node_modules/@types/node/tty.d.ts generated vendored
View File

@ -42,7 +42,10 @@ declare module 'tty' {
constructor(fd: number, options?: net.SocketConstructorOpts); constructor(fd: number, options?: net.SocketConstructorOpts);
/** /**
* A `boolean` that is `true` if the TTY is currently configured to operate as a * A `boolean` that is `true` if the TTY is currently configured to operate as a
* raw device. Defaults to `false`. * raw device.
*
* This flag is always `false` when a process starts, even if the terminal is
* operating in raw mode. Its value will change with subsequent calls to`setRawMode`.
* @since v0.7.7 * @since v0.7.7
*/ */
isRaw: boolean; isRaw: boolean;

86
node_modules/@types/node/util.d.ts generated vendored
View File

@ -1460,32 +1460,72 @@ declare module 'util' {
/** /**
* Gets and sets the type portion of the MIME. * Gets and sets the type portion of the MIME.
*
* ```js
* import { MIMEType } from 'node:util';
*
* const myMIME = new MIMEType('text/javascript');
* console.log(myMIME.type);
* // Prints: text
* myMIME.type = 'application';
* console.log(myMIME.type);
* // Prints: application
* console.log(String(myMIME));
* // Prints: application/javascript
* ```
*/ */
type: string; type: string;
/** /**
* Gets and sets the subtype portion of the MIME. * Gets and sets the subtype portion of the MIME.
*
* ```js
* import { MIMEType } from 'node:util';
*
* const myMIME = new MIMEType('text/ecmascript');
* console.log(myMIME.subtype);
* // Prints: ecmascript
* myMIME.subtype = 'javascript';
* console.log(myMIME.subtype);
* // Prints: javascript
* console.log(String(myMIME));
* // Prints: text/javascript
* ```
*/ */
subtype: string; subtype: string;
/** /**
* Gets the essence of the MIME. * Gets the essence of the MIME. This property is read only.
*
* Use `mime.type` or `mime.subtype` to alter the MIME. * Use `mime.type` or `mime.subtype` to alter the MIME.
*
* ```js
* import { MIMEType } from 'node:util';
*
* const myMIME = new MIMEType('text/javascript;key=value');
* console.log(myMIME.essence);
* // Prints: text/javascript
* myMIME.type = 'application';
* console.log(myMIME.essence);
* // Prints: application/javascript
* console.log(String(myMIME));
* // Prints: application/javascript;key=value
* ```
*/ */
readonly essence: string; readonly essence: string;
/** /**
* Gets the `MIMEParams` object representing the parameters of the MIME. * Gets the `MIMEParams` object representing the
* parameters of the MIME. This property is read-only. See `MIMEParams` documentation for details.
*/ */
readonly params: MIMEParams; readonly params: MIMEParams;
/** /**
* Returns the serialized MIME. * The `toString()` method on the `MIMEType` object returns the serialized MIME.
* *
* Because of the need for standard compliance, this method * Because of the need for standard compliance, this method does not allow users
* does not allow users to customize the serialization process of the MIME. * to customize the serialization process of the MIME.
*/ */
toString(): string; toString(): string;
} }
/** /**
* @since v18.13.0 * The `MIMEParams` API provides read and write access to the parameters of a`MIMEType`.
* @since v19.1.0, v18.13.0
*/ */
export class MIMEParams { export class MIMEParams {
/** /**
@ -1494,11 +1534,14 @@ declare module 'util' {
delete(name: string): void; delete(name: string): void;
/** /**
* Returns an iterator over each of the name-value pairs in the parameters. * Returns an iterator over each of the name-value pairs in the parameters.
* Each item of the iterator is a JavaScript `Array`. The first item of the array
* is the `name`, the second item of the array is the `value`.
*/ */
entries(): IterableIterator<[name: string, value: string]>; entries(): IterableIterator<[name: string, value: string]>;
/** /**
* Returns the value of the first name-value pair whose name is `name`. * Returns the value of the first name-value pair whose name is `name`. If there
* If there are no such pairs, `null` is returned. * are no such pairs, `null` is returned.
* @return or `null` if there is no name-value pair with the given `name`.
*/ */
get(name: string): string | null; get(name: string): string | null;
/** /**
@ -1507,12 +1550,33 @@ declare module 'util' {
has(name: string): boolean; has(name: string): boolean;
/** /**
* Returns an iterator over the names of each name-value pair. * Returns an iterator over the names of each name-value pair.
*
* ```js
* import { MIMEType } from 'node:util';
*
* const { params } = new MIMEType('text/plain;foo=0;bar=1');
* for (const name of params.keys()) {
* console.log(name);
* }
* // Prints:
* // foo
* // bar
* ```
*/ */
keys(): IterableIterator<string>; keys(): IterableIterator<string>;
/** /**
* Sets the value in the `MIMEParams` object associated with `name` to `value`. * Sets the value in the `MIMEParams` object associated with `name` to`value`. If there are any pre-existing name-value pairs whose names are `name`,
* If there are any pre-existing name-value pairs whose names are `name`,
* set the first such pair's value to `value`. * set the first such pair's value to `value`.
*
* ```js
* import { MIMEType } from 'node:util';
*
* const { params } = new MIMEType('text/plain;foo=0;bar=1');
* params.set('foo', 'def');
* params.set('baz', 'xyz');
* console.log(params.toString());
* // Prints: foo=def&#x26;bar=1&#x26;baz=xyz
* ```
*/ */
set(name: string, value: string): void; set(name: string, value: string): void;
/** /**

4
node_modules/@types/node/wasi.d.ts generated vendored
View File

@ -58,8 +58,8 @@
* *
* Use [wabt](https://github.com/WebAssembly/wabt) to compile `.wat` to `.wasm` * Use [wabt](https://github.com/WebAssembly/wabt) to compile `.wat` to `.wasm`
* *
* ```console * ```bash
* $ wat2wasm demo.wat * wat2wasm demo.wat
* ``` * ```
* @experimental * @experimental
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/wasi.js) * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/wasi.js)

View File

@ -1,39 +0,0 @@
# changes log
## 5.7
* Add `minVersion` method
## 5.6
* Move boolean `loose` param to an options object, with
backwards-compatibility protection.
* Add ability to opt out of special prerelease version handling with
the `includePrerelease` option flag.
## 5.5
* Add version coercion capabilities
## 5.4
* Add intersection checking
## 5.3
* Add `minSatisfying` method
## 5.2
* Add `prerelease(v)` that returns prerelease components
## 5.1
* Add Backus-Naur for ranges
* Remove excessively cute inspection methods
## 5.0
* Remove AMD/Browserified build artifacts
* Fix ltr and gtr when using the `*` range
* Fix for range `*` with a prerelease identifier

View File

@ -1,19 +1,26 @@
{ {
"name": "semver", "name": "semver",
"version": "5.7.1", "version": "5.7.2",
"description": "The semantic version parser used by npm.", "description": "The semantic version parser used by npm.",
"main": "semver.js", "main": "semver.js",
"scripts": { "scripts": {
"test": "tap", "test": "tap test/ --100 --timeout=30",
"preversion": "npm test", "lint": "echo linting disabled",
"postversion": "npm publish", "postlint": "template-oss-check",
"postpublish": "git push origin --all; git push origin --tags" "template-oss-apply": "template-oss-apply --force",
"lintfix": "npm run lint -- --fix",
"snap": "tap test/ --100 --timeout=30",
"posttest": "npm run lint"
}, },
"devDependencies": { "devDependencies": {
"tap": "^13.0.0-rc.18" "@npmcli/template-oss": "4.17.0",
"tap": "^12.7.0"
}, },
"license": "ISC", "license": "ISC",
"repository": "https://github.com/npm/node-semver", "repository": {
"type": "git",
"url": "https://github.com/npm/node-semver.git"
},
"bin": { "bin": {
"semver": "./bin/semver" "semver": "./bin/semver"
}, },
@ -22,7 +29,10 @@
"range.bnf", "range.bnf",
"semver.js" "semver.js"
], ],
"tap": { "author": "GitHub Inc.",
"check-coverage": true "templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"content": "./scripts/template-oss",
"version": "4.17.0"
} }
} }

View File

@ -26,11 +26,39 @@ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
// Max safe segment length for coercion. // Max safe segment length for coercion.
var MAX_SAFE_COMPONENT_LENGTH = 16 var MAX_SAFE_COMPONENT_LENGTH = 16
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
// The actual regexps go on exports.re // The actual regexps go on exports.re
var re = exports.re = [] var re = exports.re = []
var safeRe = exports.safeRe = []
var src = exports.src = [] var src = exports.src = []
var R = 0 var R = 0
var LETTERDASHNUMBER = '[a-zA-Z0-9-]'
// Replace some greedy regex tokens to prevent regex dos issues. These regex are
// used internally via the safeRe object since all inputs in this library get
// normalized first to trim and collapse all extra whitespace. The original
// regexes are exported for userland consumption and lower level usage. A
// future breaking change could export the safer regex only with a note that
// all input should have extra whitespace removed.
var safeRegexReplacements = [
['\\s', 1],
['\\d', MAX_LENGTH],
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
]
function makeSafeRe (value) {
for (var i = 0; i < safeRegexReplacements.length; i++) {
var token = safeRegexReplacements[i][0]
var max = safeRegexReplacements[i][1]
value = value
.split(token + '*').join(token + '{0,' + max + '}')
.split(token + '+').join(token + '{1,' + max + '}')
}
return value
}
// The following Regular Expressions can be used for tokenizing, // The following Regular Expressions can be used for tokenizing,
// validating, and parsing SemVer version strings. // validating, and parsing SemVer version strings.
@ -40,14 +68,14 @@ var R = 0
var NUMERICIDENTIFIER = R++ var NUMERICIDENTIFIER = R++
src[NUMERICIDENTIFIER] = '0|[1-9]\\d*' src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'
var NUMERICIDENTIFIERLOOSE = R++ var NUMERICIDENTIFIERLOOSE = R++
src[NUMERICIDENTIFIERLOOSE] = '[0-9]+' src[NUMERICIDENTIFIERLOOSE] = '\\d+'
// ## Non-numeric Identifier // ## Non-numeric Identifier
// Zero or more digits, followed by a letter or hyphen, and then zero or // Zero or more digits, followed by a letter or hyphen, and then zero or
// more letters, digits, or hyphens. // more letters, digits, or hyphens.
var NONNUMERICIDENTIFIER = R++ var NONNUMERICIDENTIFIER = R++
src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-]' + LETTERDASHNUMBER + '*'
// ## Main Version // ## Main Version
// Three dot-separated numeric identifiers. // Three dot-separated numeric identifiers.
@ -89,7 +117,7 @@ src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] +
// Any combination of digits, letters, or hyphens. // Any combination of digits, letters, or hyphens.
var BUILDIDENTIFIER = R++ var BUILDIDENTIFIER = R++
src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+' src[BUILDIDENTIFIER] = LETTERDASHNUMBER + '+'
// ## Build Metadata // ## Build Metadata
// Plus sign, followed by one or more period-separated build metadata // Plus sign, followed by one or more period-separated build metadata
@ -174,6 +202,7 @@ src[LONETILDE] = '(?:~>?)'
var TILDETRIM = R++ var TILDETRIM = R++
src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+' src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'
re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g') re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g')
safeRe[TILDETRIM] = new RegExp(makeSafeRe(src[TILDETRIM]), 'g')
var tildeTrimReplace = '$1~' var tildeTrimReplace = '$1~'
var TILDE = R++ var TILDE = R++
@ -189,6 +218,7 @@ src[LONECARET] = '(?:\\^)'
var CARETTRIM = R++ var CARETTRIM = R++
src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+' src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'
re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g') re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g')
safeRe[CARETTRIM] = new RegExp(makeSafeRe(src[CARETTRIM]), 'g')
var caretTrimReplace = '$1^' var caretTrimReplace = '$1^'
var CARET = R++ var CARET = R++
@ -210,6 +240,7 @@ src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] +
// this one has to use the /g flag // this one has to use the /g flag
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g') re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g')
safeRe[COMPARATORTRIM] = new RegExp(makeSafeRe(src[COMPARATORTRIM]), 'g')
var comparatorTrimReplace = '$1$2$3' var comparatorTrimReplace = '$1$2$3'
// Something like `1.2.3 - 1.2.4` // Something like `1.2.3 - 1.2.4`
@ -238,6 +269,14 @@ for (var i = 0; i < R; i++) {
debug(i, src[i]) debug(i, src[i])
if (!re[i]) { if (!re[i]) {
re[i] = new RegExp(src[i]) re[i] = new RegExp(src[i])
// Replace all greedy whitespace to prevent regex dos issues. These regex are
// used internally via the safeRe object since all inputs in this library get
// normalized first to trim and collapse all extra whitespace. The original
// regexes are exported for userland consumption and lower level usage. A
// future breaking change could export the safer regex only with a note that
// all input should have extra whitespace removed.
safeRe[i] = new RegExp(makeSafeRe(src[i]))
} }
} }
@ -262,7 +301,7 @@ function parse (version, options) {
return null return null
} }
var r = options.loose ? re[LOOSE] : re[FULL] var r = options.loose ? safeRe[LOOSE] : safeRe[FULL]
if (!r.test(version)) { if (!r.test(version)) {
return null return null
} }
@ -317,7 +356,7 @@ function SemVer (version, options) {
this.options = options this.options = options
this.loose = !!options.loose this.loose = !!options.loose
var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]) var m = version.trim().match(options.loose ? safeRe[LOOSE] : safeRe[FULL])
if (!m) { if (!m) {
throw new TypeError('Invalid Version: ' + version) throw new TypeError('Invalid Version: ' + version)
@ -731,6 +770,7 @@ function Comparator (comp, options) {
return new Comparator(comp, options) return new Comparator(comp, options)
} }
comp = comp.trim().split(/\s+/).join(' ')
debug('comparator', comp, options) debug('comparator', comp, options)
this.options = options this.options = options
this.loose = !!options.loose this.loose = !!options.loose
@ -747,7 +787,7 @@ function Comparator (comp, options) {
var ANY = {} var ANY = {}
Comparator.prototype.parse = function (comp) { Comparator.prototype.parse = function (comp) {
var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR] var r = this.options.loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR]
var m = comp.match(r) var m = comp.match(r)
if (!m) { if (!m) {
@ -861,9 +901,16 @@ function Range (range, options) {
this.loose = !!options.loose this.loose = !!options.loose
this.includePrerelease = !!options.includePrerelease this.includePrerelease = !!options.includePrerelease
// First, split based on boolean or || // First reduce all whitespace as much as possible so we do not have to rely
// on potentially slow regexes like \s*. This is then stored and used for
// future error messages as well.
this.raw = range this.raw = range
this.set = range.split(/\s*\|\|\s*/).map(function (range) { .trim()
.split(/\s+/)
.join(' ')
// First, split based on boolean or ||
this.set = this.raw.split('||').map(function (range) {
return this.parseRange(range.trim()) return this.parseRange(range.trim())
}, this).filter(function (c) { }, this).filter(function (c) {
// throw out any that are not relevant for whatever reason // throw out any that are not relevant for whatever reason
@ -871,7 +918,7 @@ function Range (range, options) {
}) })
if (!this.set.length) { if (!this.set.length) {
throw new TypeError('Invalid SemVer Range: ' + range) throw new TypeError('Invalid SemVer Range: ' + this.raw)
} }
this.format() this.format()
@ -890,28 +937,23 @@ Range.prototype.toString = function () {
Range.prototype.parseRange = function (range) { Range.prototype.parseRange = function (range) {
var loose = this.options.loose var loose = this.options.loose
range = range.trim()
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE] var hr = loose ? safeRe[HYPHENRANGELOOSE] : safeRe[HYPHENRANGE]
range = range.replace(hr, hyphenReplace) range = range.replace(hr, hyphenReplace)
debug('hyphen replace', range) debug('hyphen replace', range)
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace) range = range.replace(safeRe[COMPARATORTRIM], comparatorTrimReplace)
debug('comparator trim', range, re[COMPARATORTRIM]) debug('comparator trim', range, safeRe[COMPARATORTRIM])
// `~ 1.2.3` => `~1.2.3` // `~ 1.2.3` => `~1.2.3`
range = range.replace(re[TILDETRIM], tildeTrimReplace) range = range.replace(safeRe[TILDETRIM], tildeTrimReplace)
// `^ 1.2.3` => `^1.2.3` // `^ 1.2.3` => `^1.2.3`
range = range.replace(re[CARETTRIM], caretTrimReplace) range = range.replace(safeRe[CARETTRIM], caretTrimReplace)
// normalize spaces
range = range.split(/\s+/).join(' ')
// At this point, the range is completely trimmed and // At this point, the range is completely trimmed and
// ready to be split into comparators. // ready to be split into comparators.
var compRe = loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR]
var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
var set = range.split(' ').map(function (comp) { var set = range.split(' ').map(function (comp) {
return parseComparator(comp, this.options) return parseComparator(comp, this.options)
}, this).join(' ').split(/\s+/) }, this).join(' ').split(/\s+/)
@ -987,7 +1029,7 @@ function replaceTildes (comp, options) {
} }
function replaceTilde (comp, options) { function replaceTilde (comp, options) {
var r = options.loose ? re[TILDELOOSE] : re[TILDE] var r = options.loose ? safeRe[TILDELOOSE] : safeRe[TILDE]
return comp.replace(r, function (_, M, m, p, pr) { return comp.replace(r, function (_, M, m, p, pr) {
debug('tilde', comp, _, M, m, p, pr) debug('tilde', comp, _, M, m, p, pr)
var ret var ret
@ -1028,7 +1070,7 @@ function replaceCarets (comp, options) {
function replaceCaret (comp, options) { function replaceCaret (comp, options) {
debug('caret', comp, options) debug('caret', comp, options)
var r = options.loose ? re[CARETLOOSE] : re[CARET] var r = options.loose ? safeRe[CARETLOOSE] : safeRe[CARET]
return comp.replace(r, function (_, M, m, p, pr) { return comp.replace(r, function (_, M, m, p, pr) {
debug('caret', comp, _, M, m, p, pr) debug('caret', comp, _, M, m, p, pr)
var ret var ret
@ -1087,7 +1129,7 @@ function replaceXRanges (comp, options) {
function replaceXRange (comp, options) { function replaceXRange (comp, options) {
comp = comp.trim() comp = comp.trim()
var r = options.loose ? re[XRANGELOOSE] : re[XRANGE] var r = options.loose ? safeRe[XRANGELOOSE] : safeRe[XRANGE]
return comp.replace(r, function (ret, gtlt, M, m, p, pr) { return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
debug('xRange', comp, ret, gtlt, M, m, p, pr) debug('xRange', comp, ret, gtlt, M, m, p, pr)
var xM = isX(M) var xM = isX(M)
@ -1157,10 +1199,10 @@ function replaceXRange (comp, options) {
function replaceStars (comp, options) { function replaceStars (comp, options) {
debug('replaceStars', comp, options) debug('replaceStars', comp, options)
// Looseness is ignored here. star is always as loose as it gets! // Looseness is ignored here. star is always as loose as it gets!
return comp.trim().replace(re[STAR], '') return comp.trim().replace(safeRe[STAR], '')
} }
// This function is passed to string.replace(re[HYPHENRANGE]) // This function is passed to string.replace(safeRe[HYPHENRANGE])
// M, m, patch, prerelease, build // M, m, patch, prerelease, build
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
@ -1471,7 +1513,7 @@ function coerce (version) {
return null return null
} }
var match = version.match(re[COERCE]) var match = version.match(safeRe[COERCE])
if (match == null) { if (match == null) {
return null return null