feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -8,7 +8,7 @@ This package contains type definitions for eslint (https://eslint.org).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/eslint.
### Additional Details
* Last updated: Mon, 22 Jul 2024 16:38:53 GMT
* Last updated: Mon, 26 Aug 2024 07:08:02 GMT
* Dependencies: [@types/estree](https://npmjs.com/package/@types/estree), [@types/json-schema](https://npmjs.com/package/@types/json-schema)
# Credits

View File

@@ -1,6 +1,6 @@
{
"name": "@types/eslint",
"version": "9.6.0",
"version": "9.6.1",
"description": "TypeScript definitions for eslint",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/eslint",
"license": "MIT",
@@ -65,6 +65,6 @@
"@types/estree": "*",
"@types/json-schema": "*"
},
"typesPublisherContentHash": "b9dc2442a6de9477777294005e6b8dcf6c0dee1bdcf1fe79fea879291a522175",
"typesPublisherContentHash": "bc2620143f844d291da2d199e7b8e2605e3277f1941a508dc72ac92843b149b6",
"typeScriptVersion": "4.8"
}

View File

@@ -885,7 +885,16 @@ export interface BestPractices extends Linter.RulesRecord {
* @since 0.8.0
* @see https://eslint.org/docs/rules/no-void
*/
"no-void": Linter.RuleEntry<[]>;
"no-void": Linter.RuleEntry<
[
Partial<{
/**
* @default false
*/
allowAsStatement: boolean;
}>,
]
>;
/**
* Rule to disallow specified warning terms in comments.

View File

@@ -8,7 +8,7 @@ This package contains type definitions for estree (https://github.com/estree/est
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree.
### Additional Details
* Last updated: Mon, 06 Nov 2023 22:41:05 GMT
* Last updated: Wed, 18 Sep 2024 09:37:00 GMT
* Dependencies: none
# Credits

View File

@@ -353,7 +353,7 @@ export interface UnaryExpression extends BaseExpression {
export interface BinaryExpression extends BaseExpression {
type: "BinaryExpression";
operator: BinaryOperator;
left: Expression;
left: Expression | PrivateIdentifier;
right: Expression;
}
@@ -638,7 +638,7 @@ export interface ImportDeclaration extends BaseModuleDeclaration {
export interface ImportSpecifier extends BaseModuleSpecifier {
type: "ImportSpecifier";
imported: Identifier;
imported: Identifier | Literal;
}
export interface ImportExpression extends BaseExpression {
@@ -661,9 +661,10 @@ export interface ExportNamedDeclaration extends BaseModuleDeclaration {
source?: Literal | null | undefined;
}
export interface ExportSpecifier extends BaseModuleSpecifier {
export interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
type: "ExportSpecifier";
exported: Identifier;
local: Identifier | Literal;
exported: Identifier | Literal;
}
export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
@@ -673,7 +674,7 @@ export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
export interface ExportAllDeclaration extends BaseModuleDeclaration {
type: "ExportAllDeclaration";
exported: Identifier | null;
exported: Identifier | Literal | null;
source: Literal;
}

View File

@@ -1,6 +1,6 @@
{
"name": "@types/estree",
"version": "1.0.5",
"version": "1.0.6",
"description": "TypeScript definitions for estree",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree",
"license": "MIT",
@@ -20,7 +20,7 @@
},
"scripts": {},
"dependencies": {},
"typesPublisherContentHash": "6f0eeaffe488ce594e73f8df619c677d752a279b51edbc744e4aebb20db4b3a7",
"typeScriptVersion": "4.5",
"typesPublisherContentHash": "0310b41994a6f8d7530af6c53d47d8b227f32925e43718507fdb1178e05006b1",
"typeScriptVersion": "4.8",
"nonNpm": true
}

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

@@ -8,7 +8,7 @@ This package contains type definitions for jest (https://jestjs.io/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest.
### Additional Details
* Last updated: Thu, 01 Feb 2024 17:07:05 GMT
* Last updated: Wed, 23 Oct 2024 03:36:41 GMT
* Dependencies: [expect](https://npmjs.com/package/expect), [pretty-format](https://npmjs.com/package/pretty-format)
# Credits

View File

@@ -429,7 +429,7 @@ declare namespace jest {
function useRealTimers(): typeof jest;
interface MockOptions {
virtual?: boolean | undefined;
virtual?: boolean; // Intentionally omitted "| undefined" to maintain compatibility with @jest/globals
}
type MockableFunction = (...args: any[]) => any;
@@ -463,10 +463,8 @@ declare namespace jest {
}
& { [K in PropertyKeysOf<T>]: MaybeMockedDeep<T[K]> };
type MaybeMockedDeep<T> = T extends MockableFunction ? MockedFunctionDeep<T>
: T extends object // eslint-disable-line @typescript-eslint/ban-types
? MockedObjectDeep<T>
: T extends object ? MockedObjectDeep<T>
: T;
// eslint-disable-next-line @typescript-eslint/ban-types
type MaybeMocked<T> = T extends MockableFunction ? MockedFn<T> : T extends object ? MockedObject<T> : T;
type EmptyFunction = () => void;
type ArgsType<T> = T extends (...args: infer A) => any ? A : never;
@@ -610,7 +608,7 @@ declare namespace jest {
}
interface Describe {
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
(name: number | string | Function | FunctionLike, fn: EmptyFunction): void;
/** Only runs the tests inside this `describe` for the current file */
only: Describe;
@@ -1207,6 +1205,7 @@ declare namespace jest {
new(...args: any[]): any;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
interface Mock<T = any, Y extends any[] = any, C = any> extends Function, MockInstance<T, Y, C> {
new(...args: Y): T;
(this: C, ...args: Y): T;

View File

@@ -1,6 +1,6 @@
{
"name": "@types/jest",
"version": "29.5.12",
"version": "29.5.14",
"description": "TypeScript definitions for jest",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest",
"license": "MIT",
@@ -154,6 +154,7 @@
"expect": "^29.0.0",
"pretty-format": "^29.0.0"
},
"typesPublisherContentHash": "a1d256958e6f21eee1977be2bdeab2e3f22de4b65e9f4172c04e55fc1953f27e",
"typeScriptVersion": "4.6"
"peerDependencies": {},
"typesPublisherContentHash": "03b921cd51b4ea0ab99ff3733f9e799bed833eccc13adaa2aaeb088345807f4d",
"typeScriptVersion": "4.8"
}

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

@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
### Additional Details
* Last updated: Fri, 09 Aug 2024 18:08:59 GMT
* Last updated: Sat, 23 Nov 2024 04:36:04 GMT
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
# Credits

View File

@@ -45,7 +45,7 @@ declare module "assert" {
/** The `operator` property on the error instance. */
operator?: string | undefined;
/** If provided, the generated stack trace omits frames before this function. */
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
stackStartFn?: Function | undefined;
});
}
@@ -226,7 +226,7 @@ declare module "assert" {
expected: unknown,
message?: string | Error,
operator?: string,
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
stackStartFn?: Function,
): never;
/**
@@ -966,7 +966,7 @@ declare module "assert" {
* To use strict assertion mode:
*
* ```js
* import { strict as assert } from 'node:assert';COPY
* import { strict as assert } from 'node:assert';
* import assert from 'node:assert/strict';
* ```
*

View File

@@ -77,7 +77,7 @@ declare module "async_hooks" {
* executionAsyncId,
* executionAsyncResource,
* createHook,
* } from 'async_hooks';
* } from 'node:async_hooks';
* const sym = Symbol('state'); // Private symbol to avoid pollution
*
* createHook({

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

@@ -1,3 +1,8 @@
// If lib.dom.d.ts or lib.webworker.d.ts is loaded, then use the global types.
// Otherwise, use the types from node.
type _Blob = typeof globalThis extends { onmessage: any; Blob: any } ? {} : import("buffer").Blob;
type _File = typeof globalThis extends { onmessage: any; File: any } ? {} : import("buffer").File;
/**
* `Buffer` objects are used to represent a fixed-length sequence of bytes. Many
* Node.js APIs support `Buffer`s.
@@ -129,7 +134,7 @@ declare module "buffer" {
export interface BlobOptions {
/**
* One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts
* will be converted to the platform native line-ending as specified by `require('node:os').EOL`.
* will be converted to the platform native line-ending as specified by `import { EOL } from 'node:os'`.
*/
endings?: "transparent" | "native";
/**
@@ -170,6 +175,17 @@ declare module "buffer" {
* @since v15.7.0, v14.18.0
*/
arrayBuffer(): Promise<ArrayBuffer>;
/**
* The `blob.bytes()` method returns the byte of the `Blob` object as a `Promise<Uint8Array>`.
*
* ```js
* const blob = new Blob(['hello']);
* blob.bytes().then((bytes) => {
* console.log(bytes); // Outputs: Uint8Array(5) [ 104, 101, 108, 108, 111 ]
* });
* ```
*/
bytes(): Promise<Uint8Array>;
/**
* Creates and returns a new `Blob` containing a subset of this `Blob` objects
* data. The original `Blob` is not altered.
@@ -194,7 +210,7 @@ declare module "buffer" {
export interface FileOptions {
/**
* One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be
* converted to the platform native line-ending as specified by `require('node:os').EOL`.
* converted to the platform native line-ending as specified by `import { EOL } from 'node:os'`.
*/
endings?: "native" | "transparent";
/** The File content-type. */
@@ -221,10 +237,7 @@ declare module "buffer" {
}
export import atob = globalThis.atob;
export import btoa = globalThis.btoa;
import { Blob as NodeBlob } from "buffer";
// This conditional type will be the existing global Blob in a browser, or
// the copy below in a Node environment.
type __Blob = typeof globalThis extends { onmessage: any; Blob: any } ? {} : NodeBlob;
global {
namespace NodeJS {
export { BufferEncoding };
@@ -254,100 +267,9 @@ declare module "buffer" {
* Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'
*/
interface BufferConstructor {
/**
* Allocates a new buffer containing the given {str}.
*
* @param str String to store in buffer.
* @param encoding encoding to use, optional. Default is 'utf8'
* @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
*/
new(str: string, encoding?: BufferEncoding): Buffer;
/**
* Allocates a new buffer of {size} octets.
*
* @param size count of octets to allocate.
* @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
*/
new(size: number): Buffer;
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
*/
new(array: Uint8Array): Buffer;
/**
* Produces a Buffer backed by the same allocated memory as
* the given {ArrayBuffer}/{SharedArrayBuffer}.
*
* @param arrayBuffer The ArrayBuffer with which to share memory.
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
*/
new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
*/
new(array: readonly any[]): Buffer;
/**
* Copies the passed {buffer} data onto a new {Buffer} instance.
*
* @param buffer The buffer to copy.
* @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
*/
new(buffer: Buffer): Buffer;
/**
* Allocates a new `Buffer` using an `array` of bytes in the range `0` `255`.
* Array entries outside that range will be truncated to fit into it.
*
* ```js
* import { Buffer } from 'node:buffer';
*
* // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
* 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
* appropriate for `Buffer.from()` variants.
*
* `Buffer.from(array)` and `Buffer.from(string)` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
* @since v5.10.0
*/
from(
arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
byteOffset?: number,
length?: number,
): Buffer;
/**
* Creates a new Buffer using the passed {data}
* @param data data to create a new Buffer
*/
from(data: Uint8Array | readonly number[]): Buffer;
from(data: WithImplicitCoercion<Uint8Array | readonly number[] | string>): Buffer;
/**
* Creates a new Buffer containing the given JavaScript string {str}.
* If provided, the {encoding} parameter identifies the character encoding.
* If not provided, {encoding} defaults to 'utf8'.
*/
from(
str:
| WithImplicitCoercion<string>
| {
[Symbol.toPrimitive](hint: "string"): string;
},
encoding?: BufferEncoding,
): Buffer;
/**
* Creates a new Buffer using the passed {data}
* @param values to create a new Buffer
*/
of(...items: number[]): Buffer;
// see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
// see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
/**
* Returns `true` if `obj` is a `Buffer`, `false` otherwise.
*
@@ -419,62 +341,6 @@ declare module "buffer" {
string: string | Buffer | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
encoding?: BufferEncoding,
): number;
/**
* Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
*
* If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
*
* If `totalLength` is not provided, it is calculated from the `Buffer` instances
* in `list` by adding their lengths.
*
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
* truncated to `totalLength`.
*
* ```js
* import { Buffer } from 'node:buffer';
*
* // Create a single `Buffer` from a list of three `Buffer` instances.
*
* const buf1 = Buffer.alloc(10);
* const buf2 = Buffer.alloc(14);
* const buf3 = Buffer.alloc(18);
* const totalLength = buf1.length + buf2.length + buf3.length;
*
* console.log(totalLength);
* // Prints: 42
*
* const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
*
* console.log(bufA);
* // Prints: <Buffer 00 00 00 00 ...>
* console.log(bufA.length);
* // Prints: 42
* ```
*
* `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
* @since v0.7.11
* @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
* @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
*/
concat(list: readonly Uint8Array[], totalLength?: number): Buffer;
/**
* Copies the underlying memory of `view` into a new `Buffer`.
*
* ```js
* const u16 = new Uint16Array([0, 0xffff]);
* const buf = Buffer.copyBytesFrom(u16, 1, 1);
* u16[1] = 0;
* console.log(buf.length); // 2
* console.log(buf[0]); // 255
* console.log(buf[1]); // 255
* ```
* @since v19.8.0
* @param view The {TypedArray} to copy.
* @param [offset=0] The starting offset within `view`.
* @param [length=view.length - offset] The number of elements from `view` to copy.
*/
copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer;
/**
* Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of `Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
*
@@ -493,135 +359,6 @@ declare module "buffer" {
* @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
*/
compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1;
/**
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
*
* ```js
* import { Buffer } from 'node:buffer';
*
* const buf = Buffer.alloc(5);
*
* console.log(buf);
* // Prints: <Buffer 00 00 00 00 00>
* ```
*
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
*
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
*
* ```js
* import { Buffer } from 'node:buffer';
*
* const buf = Buffer.alloc(5, 'a');
*
* console.log(buf);
* // Prints: <Buffer 61 61 61 61 61>
* ```
*
* If both `fill` and `encoding` are specified, the allocated `Buffer` will be
* initialized by calling `buf.fill(fill, encoding)`.
*
* ```js
* import { Buffer } from 'node:buffer';
*
* const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
*
* console.log(buf);
* // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
* ```
*
* Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
* contents will never contain sensitive data from previous allocations, including
* data that might not have been allocated for `Buffer`s.
*
* A `TypeError` will be thrown if `size` is not a number.
* @since v5.10.0
* @param size The desired length of the new `Buffer`.
* @param [fill=0] A value to pre-fill the new `Buffer` with.
* @param [encoding='utf8'] If `fill` is a string, this is its encoding.
*/
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.
*
* The underlying memory for `Buffer` instances created in this way is _not_
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
*
* ```js
* import { Buffer } from 'node:buffer';
*
* const buf = Buffer.allocUnsafe(10);
*
* console.log(buf);
* // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
*
* buf.fill(0);
*
* console.log(buf);
* // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
* ```
*
* A `TypeError` will be thrown if `size` is not a number.
*
* 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)`,
* and `Buffer.concat()` only when `size` is less than `Buffer.poolSize >>> 1` (floor of `Buffer.poolSize` divided by two).
*
* Use of this pre-allocated internal memory pool is a key difference between
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
* Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
* than or equal to half `Buffer.poolSize`. The
* difference is subtle but can be important when an application requires the
* additional performance that `Buffer.allocUnsafe()` provides.
* @since v5.10.0
* @param size The desired length of the new `Buffer`.
*/
allocUnsafe(size: number): 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. A zero-length `Buffer` is created if
* `size` is 0.
*
* The underlying memory for `Buffer` instances created in this way is _not_
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
* such `Buffer` instances with zeroes.
*
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
* allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
* allows applications to avoid the garbage collection overhead of creating many
* individually allocated `Buffer` instances. This approach improves both
* performance and memory usage by eliminating the need to track and clean up as
* many individual `ArrayBuffer` objects.
*
* However, in the case where a developer may need to retain a small chunk of
* memory from a pool for an indeterminate amount of time, it may be appropriate
* to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
* then copying out the relevant bits.
*
* ```js
* import { Buffer } from 'node:buffer';
*
* // Need to keep around a few small chunks of memory.
* const store = [];
*
* socket.on('readable', () => {
* let data;
* while (null !== (data = readable.read())) {
* // Allocate for retained data.
* const sb = Buffer.allocUnsafeSlow(10);
*
* // Copy the data into the new allocation.
* data.copy(sb, 0, 0, 10);
*
* store.push(sb);
* }
* });
* ```
*
* A `TypeError` will be thrown if `size` is not a number.
* @since v5.12.0
* @param size The desired length of the new `Buffer`.
*/
allocUnsafeSlow(size: number): Buffer;
/**
* This is the size (in bytes) of pre-allocated internal `Buffer` instances used
* for pooling. This value may be modified.
@@ -629,7 +366,10 @@ declare module "buffer" {
*/
poolSize: number;
}
interface Buffer extends Uint8Array {
interface Buffer {
// see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
// see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
/**
* Writes `string` to `buf` at `offset` according to the character encoding in`encoding`. The `length` parameter is the number of bytes to write. If `buf` did
* not contain enough space to fit the entire string, only part of `string` will be
@@ -866,100 +606,6 @@ declare module "buffer" {
* @return The number of bytes copied.
*/
copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
/**
* Returns a new `Buffer` that references the same memory as the original, but
* offset and cropped by the `start` and `end` indices.
*
* This method is not compatible with the `Uint8Array.prototype.slice()`,
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
*
* ```js
* import { Buffer } from 'node:buffer';
*
* const buf = Buffer.from('buffer');
*
* const copiedBuf = Uint8Array.prototype.slice.call(buf);
* copiedBuf[0]++;
* console.log(copiedBuf.toString());
* // Prints: cuffer
*
* console.log(buf.toString());
* // Prints: buffer
*
* // With buf.slice(), the original buffer is modified.
* const notReallyCopiedBuf = buf.slice();
* notReallyCopiedBuf[0]++;
* console.log(notReallyCopiedBuf.toString());
* // Prints: cuffer
* console.log(buf.toString());
* // Also prints: cuffer (!)
* ```
* @since v0.3.0
* @deprecated Use `subarray` instead.
* @param [start=0] Where the new `Buffer` will start.
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
*/
slice(start?: number, end?: number): Buffer;
/**
* Returns a new `Buffer` that references the same memory as the original, but
* offset and cropped by the `start` and `end` indices.
*
* Specifying `end` greater than `buf.length` will return the same result as
* that of `end` equal to `buf.length`.
*
* This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
*
* Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
*
* ```js
* import { Buffer } from 'node:buffer';
*
* // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
* // from the original `Buffer`.
*
* const buf1 = Buffer.allocUnsafe(26);
*
* for (let i = 0; i < 26; i++) {
* // 97 is the decimal ASCII value for 'a'.
* buf1[i] = i + 97;
* }
*
* const buf2 = buf1.subarray(0, 3);
*
* console.log(buf2.toString('ascii', 0, buf2.length));
* // Prints: abc
*
* buf1[0] = 33;
*
* console.log(buf2.toString('ascii', 0, buf2.length));
* // Prints: !bc
* ```
*
* Specifying negative indexes causes the slice to be generated relative to the
* end of `buf` rather than the beginning.
*
* ```js
* import { Buffer } from 'node:buffer';
*
* const buf = Buffer.from('buffer');
*
* console.log(buf.subarray(-6, -1).toString());
* // Prints: buffe
* // (Equivalent to buf.subarray(0, 5).)
*
* console.log(buf.subarray(-6, -2).toString());
* // Prints: buff
* // (Equivalent to buf.subarray(0, 4).)
*
* console.log(buf.subarray(-5, -2).toString());
* // Prints: uff
* // (Equivalent to buf.subarray(1, 4).)
* ```
* @since v3.0.0
* @param [start=0] Where the new `Buffer` will start.
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
*/
subarray(start?: number, end?: number): Buffer;
/**
* Writes `value` to `buf` at the specified `offset` as big-endian.
*
@@ -1617,7 +1263,7 @@ declare module "buffer" {
* @since v5.10.0
* @return A reference to `buf`.
*/
swap16(): Buffer;
swap16(): this;
/**
* Interprets `buf` as an array of unsigned 32-bit integers and swaps the
* byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
@@ -1643,7 +1289,7 @@ declare module "buffer" {
* @since v5.10.0
* @return A reference to `buf`.
*/
swap32(): Buffer;
swap32(): this;
/**
* Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_.
* Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
@@ -1669,7 +1315,7 @@ declare module "buffer" {
* @since v6.3.0
* @return A reference to `buf`.
*/
swap64(): Buffer;
swap64(): this;
/**
* Writes `value` to `buf` at the specified `offset`. `value` must be a
* valid unsigned 8-bit integer. Behavior is undefined when `value` is anything
@@ -2264,17 +1910,22 @@ declare module "buffer" {
* @param data An ASCII (Latin1) string.
*/
function btoa(data: string): string;
interface Blob extends __Blob {}
interface Blob extends _Blob {}
/**
* `Blob` class is a global reference for `require('node:buffer').Blob`
* `Blob` class is a global reference for `import { Blob } from 'node:buffer'`
* https://nodejs.org/api/buffer.html#class-blob
* @since v18.0.0
*/
var Blob: typeof globalThis extends {
onmessage: any;
Blob: infer T;
} ? T
: typeof NodeBlob;
var Blob: typeof globalThis extends { onmessage: any; Blob: infer T } ? T
: typeof import("buffer").Blob;
interface File extends _File {}
/**
* `File` class is a global reference for `import { File } from 'node:buffer'`
* https://nodejs.org/api/buffer.html#class-file
* @since v20.0.0
*/
var File: typeof globalThis extends { onmessage: any; File: infer T } ? T
: typeof import("buffer").File;
}
}
declare module "node:buffer" {

View File

@@ -4,7 +4,7 @@
* is primarily provided by the {@link spawn} function:
*
* ```js
* const { spawn } = require('node:child_process');
* import { spawn } from 'node:child_process';
* const ls = spawn('ls', ['-lh', '/usr']);
*
* ls.stdout.on('data', (data) => {
@@ -109,7 +109,7 @@ declare module "child_process" {
* refer to the same value.
*
* ```js
* const { spawn } = require('node:child_process');
* import { spawn } from 'node:child_process';
*
* const subprocess = spawn('ls');
*
@@ -152,9 +152,9 @@ declare module "child_process" {
* in the array are `null`.
*
* ```js
* const assert = require('node:assert');
* const fs = require('node:fs');
* const child_process = require('node:child_process');
* import assert from 'node:assert';
* import fs from 'node:fs';
* import child_process from 'node:child_process';
*
* const subprocess = child_process.spawn('ls', {
* stdio: [
@@ -202,7 +202,7 @@ declare module "child_process" {
* emitted.
*
* ```js
* const { spawn } = require('node:child_process');
* import { spawn } from 'node:child_process';
* const grep = spawn('grep', ['ssh']);
*
* console.log(`Spawned child pid: ${grep.pid}`);
@@ -249,7 +249,7 @@ declare module "child_process" {
* returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
*
* ```js
* const { spawn } = require('node:child_process');
* import { spawn } from 'node:child_process';
* const grep = spawn('grep', ['ssh']);
*
* grep.on('close', (code, signal) => {
@@ -282,7 +282,7 @@ declare module "child_process" {
*
* ```js
* 'use strict';
* const { spawn } = require('node:child_process');
* import { spawn } from 'node:child_process';
*
* const subprocess = spawn(
* 'sh',
@@ -320,7 +320,7 @@ declare module "child_process" {
* For example, in the parent script:
*
* ```js
* const cp = require('node:child_process');
* import cp from 'node:child_process';
* const n = cp.fork(`${__dirname}/sub.js`);
*
* n.on('message', (m) => {
@@ -374,10 +374,12 @@ declare module "child_process" {
* a TCP server object to the child process as illustrated in the example below:
*
* ```js
* const subprocess = require('node:child_process').fork('subprocess.js');
* import { createServer } from 'node:net';
* import { fork } from 'node:child_process';
* const subprocess = fork('subprocess.js');
*
* // Open up the server object and send the handle.
* const server = require('node:net').createServer();
* const server = createServer();
* server.on('connection', (socket) => {
* socket.end('handled by parent');
* });
@@ -412,13 +414,14 @@ declare module "child_process" {
* handle connections with "normal" or "special" priority:
*
* ```js
* const { fork } = require('node:child_process');
* import { createServer } from 'node:net';
* import { fork } from 'node:child_process';
* const normal = fork('subprocess.js', ['normal']);
* const special = fork('subprocess.js', ['special']);
*
* // Open up the server and send sockets to child. Use pauseOnConnect to prevent
* // the sockets from being read before they are sent to the child process.
* const server = require('node:net').createServer({ pauseOnConnect: true });
* const server = createServer({ pauseOnConnect: true });
* server.on('connection', (socket) => {
*
* // If this is special priority...
@@ -490,7 +493,7 @@ declare module "child_process" {
* the child and the parent.
*
* ```js
* const { spawn } = require('node:child_process');
* import { spawn } from 'node:child_process';
*
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
* detached: true,
@@ -508,7 +511,7 @@ declare module "child_process" {
* to wait for the child to exit before exiting itself.
*
* ```js
* const { spawn } = require('node:child_process');
* import { spawn } from 'node:child_process';
*
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
* detached: true,
@@ -711,7 +714,7 @@ declare module "child_process" {
* exit code:
*
* ```js
* const { spawn } = require('node:child_process');
* import { spawn } from 'node:child_process';
* const ls = spawn('ls', ['-lh', '/usr']);
*
* ls.stdout.on('data', (data) => {
@@ -730,7 +733,7 @@ declare module "child_process" {
* Example: A very elaborate way to run `ps ax | grep ssh`
*
* ```js
* const { spawn } = require('node:child_process');
* import { spawn } from 'node:child_process';
* const ps = spawn('ps', ['ax']);
* const grep = spawn('grep', ['ssh']);
*
@@ -767,7 +770,7 @@ declare module "child_process" {
* Example of checking for failed `spawn`:
*
* ```js
* const { spawn } = require('node:child_process');
* import { spawn } from 'node:child_process';
* const subprocess = spawn('bad_command');
*
* subprocess.on('error', (err) => {
@@ -785,7 +788,7 @@ declare module "child_process" {
* the error passed to the callback will be an `AbortError`:
*
* ```js
* const { spawn } = require('node:child_process');
* import { spawn } from 'node:child_process';
* const controller = new AbortController();
* const { signal } = controller;
* const grep = spawn('grep', ['ssh'], { signal });
@@ -906,7 +909,7 @@ declare module "child_process" {
* need to be dealt with accordingly:
*
* ```js
* const { exec } = require('node:child_process');
* import { exec } from 'node:child_process';
*
* exec('"/path/to/test file/test.sh" arg1 arg2');
* // Double quotes are used so that the space in the path is not interpreted as
@@ -932,7 +935,7 @@ declare module "child_process" {
* encoding, `Buffer` objects will be passed to the callback instead.
*
* ```js
* const { exec } = require('node:child_process');
* import { exec } from 'node:child_process';
* exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
* if (error) {
* console.error(`exec error: ${error}`);
@@ -957,8 +960,9 @@ declare module "child_process" {
* callback, but with two additional properties `stdout` and `stderr`.
*
* ```js
* const util = require('node:util');
* const exec = util.promisify(require('node:child_process').exec);
* import util from 'node:util';
* import child_process from 'node:child_process';
* const exec = util.promisify(child_process.exec);
*
* async function lsExample() {
* const { stdout, stderr } = await exec('ls');
@@ -972,7 +976,7 @@ declare module "child_process" {
* the error passed to the callback will be an `AbortError`:
*
* ```js
* const { exec } = require('node:child_process');
* import { exec } from 'node:child_process';
* const controller = new AbortController();
* const { signal } = controller;
* const child = exec('grep ssh', { signal }, (error) => {
@@ -1096,7 +1100,7 @@ declare module "child_process" {
* supported.
*
* ```js
* const { execFile } = require('node:child_process');
* import { execFile } from 'node:child_process';
* const child = execFile('node', ['--version'], (error, stdout, stderr) => {
* if (error) {
* throw error;
@@ -1119,8 +1123,9 @@ declare module "child_process" {
* callback, but with two additional properties `stdout` and `stderr`.
*
* ```js
* const util = require('node:util');
* const execFile = util.promisify(require('node:child_process').execFile);
* import util from 'node:util';
* import child_process from 'node:child_process';
* const execFile = util.promisify(child_process.execFile);
* async function getVersion() {
* const { stdout } = await execFile('node', ['--version']);
* console.log(stdout);
@@ -1136,7 +1141,7 @@ declare module "child_process" {
* the error passed to the callback will be an `AbortError`:
*
* ```js
* const { execFile } = require('node:child_process');
* import { execFile } from 'node:child_process';
* const controller = new AbortController();
* const { signal } = controller;
* const child = execFile('node', ['--version'], { signal }, (error) => {
@@ -1377,7 +1382,7 @@ declare module "child_process" {
* console.log(`Hello from ${process.argv[2]}!`);
* }, 1_000);
* } else {
* const { fork } = require('node:child_process');
* import { fork } from 'node:child_process';
* const controller = new AbortController();
* const { signal } = controller;
* const child = fork(__filename, ['child'], { signal });

View File

@@ -231,6 +231,8 @@ declare module "cluster" {
* the `'disconnect'` event has not been emitted after some time.
*
* ```js
* import net from 'node:net';
*
* if (cluster.isPrimary) {
* const worker = cluster.fork();
* let timeout;
@@ -248,7 +250,6 @@ declare module "cluster" {
* });
*
* } else if (cluster.isWorker) {
* const net = require('node:net');
* const server = net.createServer((socket) => {
* // Connections never end
* });

View File

@@ -6,7 +6,7 @@
*
* * A `Console` class with methods such as `console.log()`, `console.error()`, and `console.warn()` that can be used to write to any Node.js stream.
* * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and
* [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without calling `require('node:console')`.
* [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
*
* _**Warning**_: The global console object's methods are neither consistently
* synchronous like the browser APIs they resemble, nor are they consistently
@@ -362,7 +362,7 @@ declare module "node:console" {
*
* * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream.
* * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and
* [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without calling `require('console')`.
* [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
*
* _**Warning**_: The global console object's methods are neither consistently
* synchronous like the browser APIs they resemble, nor are they consistently

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

@@ -609,11 +609,6 @@ declare module "crypto" {
* @since v11.6.0
*/
asymmetricKeyType?: KeyType | undefined;
/**
* For asymmetric keys, this property represents the size of the embedded key in
* bytes. This property is `undefined` for symmetric keys.
*/
asymmetricKeySize?: number | undefined;
/**
* This property exists only on asymmetric keys. Depending on the type of the key,
* this object contains information about the key. None of the information obtained
@@ -2139,7 +2134,10 @@ declare module "crypto" {
* be passed instead of a public key.
* @since v0.11.14
*/
function publicEncrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
function publicEncrypt(
key: RsaPublicKey | RsaPrivateKey | KeyLike,
buffer: NodeJS.ArrayBufferView | string,
): Buffer;
/**
* Decrypts `buffer` with `key`.`buffer` was previously encrypted using
* the corresponding private key, for example using {@link privateEncrypt}.
@@ -2151,7 +2149,10 @@ declare module "crypto" {
* be passed instead of a public key.
* @since v1.1.0
*/
function publicDecrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
function publicDecrypt(
key: RsaPublicKey | RsaPrivateKey | KeyLike,
buffer: NodeJS.ArrayBufferView | string,
): Buffer;
/**
* Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
* the corresponding public key, for example using {@link publicEncrypt}.
@@ -2160,7 +2161,7 @@ declare module "crypto" {
* object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_OAEP_PADDING`.
* @since v0.11.14
*/
function privateDecrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
function privateDecrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView | string): Buffer;
/**
* Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
* the corresponding public key, for example using {@link publicDecrypt}.
@@ -2169,7 +2170,7 @@ declare module "crypto" {
* object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_PADDING`.
* @since v1.1.0
*/
function privateEncrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
function privateEncrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView | string): Buffer;
/**
* ```js
* const {
@@ -3316,8 +3317,8 @@ declare module "crypto" {
* Example:
*
* ```js
* const crypto = require('node:crypto');
* const { Buffer } = require('node:buffer');
* import crypto from 'node:crypto';
* import { Buffer } from 'node:buffer';
*
* // Hashing a string and return the result as a hex-encoded string.
* const string = 'Node.js';
@@ -4034,7 +4035,7 @@ declare module "crypto" {
saltLength: number;
}
/**
* Calling `require('node:crypto').webcrypto` returns an instance of the `Crypto` class.
* Importing the `webcrypto` object (`import { webcrypto } from 'node:crypto'`) gives an instance of the `Crypto` class.
* `Crypto` is a singleton that provides access to the remainder of the crypto API.
* @since v15.0.0
*/

View File

@@ -540,11 +540,11 @@ declare module "diagnostics_channel" {
* @param args Optional arguments to pass to the function
* @return The return value of the given function
*/
traceCallback<Fn extends (this: any, ...args: any) => any>(
traceCallback<Fn extends (this: any, ...args: any[]) => any>(
fn: Fn,
position: number | undefined,
context: ContextType | undefined,
thisArg: any,
position?: number,
context?: ContextType,
thisArg?: any,
...args: Parameters<Fn>
): void;
}

10
node_modules/@types/node/dns.d.ts generated vendored
View File

@@ -9,7 +9,7 @@
* system do, use {@link lookup}.
*
* ```js
* const dns = require('node:dns');
* import dns from 'node:dns';
*
* dns.lookup('example.org', (err, address, family) => {
* console.log('address: %j family: IPv%s', address, family);
@@ -23,7 +23,7 @@
* DNS queries, bypassing other name-resolution facilities.
*
* ```js
* const dns = require('node:dns');
* import dns from 'node:dns';
*
* dns.resolve4('archive.org', (err, addresses) => {
* if (err) throw err;
@@ -139,7 +139,7 @@ declare module "dns" {
* Example usage:
*
* ```js
* const dns = require('node:dns');
* import dns from 'node:dns';
* const options = {
* family: 6,
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
@@ -199,7 +199,7 @@ declare module "dns" {
* where `err.code` is the error code.
*
* ```js
* const dns = require('node:dns');
* import dns from 'node:dns';
* dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
* console.log(hostname, service);
* // Prints: localhost ssh
@@ -787,7 +787,7 @@ declare module "dns" {
* other resolvers:
*
* ```js
* const { Resolver } = require('node:dns');
* import { Resolver } from 'node:dns';
* const resolver = new Resolver();
* resolver.setServers(['4.4.4.4']);
*

View File

@@ -1,7 +1,7 @@
/**
* The `dns.promises` API provides an alternative set of asynchronous DNS methods
* that return `Promise` objects rather than using callbacks. The API is accessible
* via `require('node:dns').promises` or `require('node:dns/promises')`.
* via `import { promises as dnsPromises } from 'node:dns'` or `import dnsPromises from 'node:dns/promises'`.
* @since v10.6.0
*/
declare module "dns/promises" {
@@ -60,7 +60,7 @@ declare module "dns/promises" {
* Example usage:
*
* ```js
* const dns = require('node:dns');
* import dns from 'node:dns';
* const dnsPromises = dns.promises;
* const options = {
* family: 6,
@@ -96,7 +96,7 @@ declare module "dns/promises" {
* On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is the error code.
*
* ```js
* const dnsPromises = require('node:dns').promises;
* import dnsPromises from 'node:dns';
* dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
* console.log(result.hostname, result.service);
* // Prints: localhost ssh
@@ -394,8 +394,8 @@ declare module "dns/promises" {
* other resolvers:
*
* ```js
* const { Resolver } = require('node:dns').promises;
* const resolver = new Resolver();
* import { promises } from 'node:dns';
* const resolver = new promises.Resolver();
* resolver.setServers(['4.4.4.4']);
*
* // This request will use the server at 4.4.4.4, independent of global settings.

View File

@@ -63,8 +63,8 @@ declare module "domain" {
* This is the most basic way to use a domain.
*
* ```js
* const domain = require('node:domain');
* const fs = require('node:fs');
* import domain from 'node:domain';
* import fs from 'node:fs';
* const d = domain.create();
* d.on('error', (er) => {
* console.error('Caught error!', er);

View File

@@ -304,12 +304,12 @@ declare module "events" {
emitter: NodeJS.EventEmitter,
eventName: string | symbol,
options?: StaticEventEmitterIteratorOptions,
): AsyncIterableIterator<any[]>;
): NodeJS.AsyncIterator<any[]>;
static on(
emitter: EventTarget,
eventName: string,
options?: StaticEventEmitterIteratorOptions,
): AsyncIterableIterator<any[]>;
): NodeJS.AsyncIterator<any[]>;
/**
* A class method that returns the number of listeners for the given `eventName` registered on the given `emitter`.
*
@@ -396,7 +396,7 @@ declare module "events" {
* ```
* @since v15.4.0
* @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
* @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
* @param eventTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
* objects.
*/
static setMaxListeners(n?: number, ...eventTargets: Array<EventTarget | NodeJS.EventEmitter>): void;

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

@@ -284,7 +284,7 @@ declare module "fs" {
/**
* Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
*/
[Symbol.asyncIterator](): AsyncIterableIterator<Dirent>;
[Symbol.asyncIterator](): NodeJS.AsyncIterator<Dirent>;
/**
* Asynchronously close the directory's underlying resource handle.
* Subsequent reads will result in errors.
@@ -1900,7 +1900,7 @@ declare module "fs" {
* The `fs.mkdtemp()` method will append the six randomly selected characters
* directly to the `prefix` string. For instance, given a directory `/tmp`, if the
* intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator
* (`require('node:path').sep`).
* (`import { sep } from 'node:path'`).
*
* ```js
* import { tmpdir } from 'node:os';
@@ -3156,7 +3156,7 @@ declare module "fs" {
* stat object:
*
* ```js
* import { watchFile } from 'fs';
* import { watchFile } from 'node:fs';
*
* watchFile('message.text', (curr, prev) => {
* console.log(`the current mtime is: ${curr.mtime}`);
@@ -4314,29 +4314,35 @@ declare module "fs" {
*/
export function cpSync(source: string | URL, destination: string | URL, opts?: CopySyncOptions): void;
export interface GlobOptions {
interface GlobOptionsBase {
/**
* Current working directory.
* @default process.cwd()
*/
cwd?: string | undefined;
/**
* Function to filter out files/directories. Return true to exclude the item, false to include it.
*/
exclude?: ((fileName: string) => boolean) | undefined;
/**
* `true` if the glob should return paths as `Dirent`s, `false` otherwise.
* @default false
* @since v22.2.0
*/
withFileTypes?: boolean | undefined;
/**
* Function to filter out files/directories. Return true to exclude the item, false to include it.
*/
exclude?: ((fileName: any) => boolean) | undefined;
}
export interface GlobOptionsWithFileTypes extends GlobOptions {
export interface GlobOptionsWithFileTypes extends GlobOptionsBase {
exclude?: ((fileName: Dirent) => boolean) | undefined;
withFileTypes: true;
}
export interface GlobOptionsWithoutFileTypes extends GlobOptions {
export interface GlobOptionsWithoutFileTypes extends GlobOptionsBase {
exclude?: ((fileName: string) => boolean) | undefined;
withFileTypes?: false | undefined;
}
export interface GlobOptions extends GlobOptionsBase {
exclude?: ((fileName: Dirent | string) => boolean) | undefined;
}
/**
* Retrieves the files matching the specified pattern.
*/

View File

@@ -238,6 +238,10 @@ declare module "fs/promises" {
length?: number | null,
position?: number | null,
): Promise<FileReadResult<T>>;
read<T extends NodeJS.ArrayBufferView = Buffer>(
buffer: T,
options?: FileReadOptions<T>,
): Promise<FileReadResult<T>>;
read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
/**
* Returns a `ReadableStream` that may be used to read the files data.
@@ -429,6 +433,13 @@ declare module "fs/promises" {
bytesWritten: number;
buffer: TBuffer;
}>;
write<TBuffer extends Uint8Array>(
buffer: TBuffer,
options?: { offset?: number; length?: number; position?: number },
): Promise<{
bytesWritten: number;
buffer: TBuffer;
}>;
write(
data: string,
position?: number | null,
@@ -932,7 +943,7 @@ declare module "fs/promises" {
* The `fsPromises.mkdtemp()` method will append the six randomly selected
* characters directly to the `prefix` string. For instance, given a directory `/tmp`, if the intention is to create a temporary directory _within_ `/tmp`, the `prefix` must end with a trailing
* platform-specific path separator
* (`require('node:path').sep`).
* (`import { sep } from 'node:path'`).
* @since v10.0.0
* @return Fulfills with a string containing the file system path of the newly created temporary directory.
*/
@@ -1174,7 +1185,7 @@ declare module "fs/promises" {
* Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
*
* ```js
* const { watch } = require('node:fs/promises');
* import { watch } from 'node:fs/promises';
*
* const ac = new AbortController();
* const { signal } = ac;
@@ -1245,19 +1256,19 @@ declare module "fs/promises" {
/**
* Retrieves the files matching the specified pattern.
*/
function glob(pattern: string | string[]): AsyncIterableIterator<string>;
function glob(pattern: string | string[]): NodeJS.AsyncIterator<string>;
function glob(
pattern: string | string[],
opt: GlobOptionsWithFileTypes,
): AsyncIterableIterator<Dirent>;
): NodeJS.AsyncIterator<Dirent>;
function glob(
pattern: string | string[],
opt: GlobOptionsWithoutFileTypes,
): AsyncIterableIterator<string>;
): NodeJS.AsyncIterator<string>;
function glob(
pattern: string | string[],
opt: GlobOptions,
): AsyncIterableIterator<Dirent> | AsyncIterableIterator<string>;
): NodeJS.AsyncIterator<Dirent | string>;
}
declare module "node:fs/promises" {
export * from "fs/promises";

279
node_modules/@types/node/globals.d.ts generated vendored
View File

@@ -2,19 +2,133 @@ export {}; // Make this a module
// #region Fetch and friends
// Conditional type aliases, used at the end of this file.
// Will either be empty if lib-dom is included, or the undici version otherwise.
// Will either be empty if lib.dom (or lib.webworker) is included, or the undici version otherwise.
type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
type _Response = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Response;
type _FormData = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").FormData;
type _Headers = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Headers;
type _MessageEvent = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").MessageEvent;
type _RequestInit = typeof globalThis extends { onmessage: any } ? {}
: import("undici-types").RequestInit;
type _ResponseInit = typeof globalThis extends { onmessage: any } ? {}
: import("undici-types").ResponseInit;
type _File = typeof globalThis extends { onmessage: any } ? {} : import("node:buffer").File;
type _WebSocket = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").WebSocket;
type _EventSource = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").EventSource;
// #endregion Fetch and friends
// Conditional type definitions for webstorage interface, which conflicts with lib.dom otherwise.
type _Storage = typeof globalThis extends { onabort: any } ? {} : {
/**
* Returns the number of key/value pairs.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/length)
*/
readonly length: number;
/**
* Removes all key/value pairs, if there are any.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/clear)
*/
clear(): void;
/**
* Returns the current value associated with the given key, or null if the given key does not exist.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/getItem)
*/
getItem(key: string): string | null;
/**
* Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/key)
*/
key(index: number): string | null;
/**
* Removes the key/value pair with the given key, if a key/value pair with the given key exists.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/removeItem)
*/
removeItem(key: string): void;
/**
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
*
* Throws a "QuotaExceededError" DOMException exception if the new value couldn't be set.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/setItem)
*/
setItem(key: string, value: string): void;
[key: string]: any;
};
// #region DOMException
type _DOMException = typeof globalThis extends { onmessage: any } ? {} : NodeDOMException;
interface NodeDOMException extends Error {
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
*/
readonly code: number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */
readonly message: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */
readonly name: string;
readonly INDEX_SIZE_ERR: 1;
readonly DOMSTRING_SIZE_ERR: 2;
readonly HIERARCHY_REQUEST_ERR: 3;
readonly WRONG_DOCUMENT_ERR: 4;
readonly INVALID_CHARACTER_ERR: 5;
readonly NO_DATA_ALLOWED_ERR: 6;
readonly NO_MODIFICATION_ALLOWED_ERR: 7;
readonly NOT_FOUND_ERR: 8;
readonly NOT_SUPPORTED_ERR: 9;
readonly INUSE_ATTRIBUTE_ERR: 10;
readonly INVALID_STATE_ERR: 11;
readonly SYNTAX_ERR: 12;
readonly INVALID_MODIFICATION_ERR: 13;
readonly NAMESPACE_ERR: 14;
readonly INVALID_ACCESS_ERR: 15;
readonly VALIDATION_ERR: 16;
readonly TYPE_MISMATCH_ERR: 17;
readonly SECURITY_ERR: 18;
readonly NETWORK_ERR: 19;
readonly ABORT_ERR: 20;
readonly URL_MISMATCH_ERR: 21;
readonly QUOTA_EXCEEDED_ERR: 22;
readonly TIMEOUT_ERR: 23;
readonly INVALID_NODE_TYPE_ERR: 24;
readonly DATA_CLONE_ERR: 25;
}
interface NodeDOMExceptionConstructor {
prototype: DOMException;
new(message?: string, nameOrOptions?: string | { name?: string; cause?: unknown }): DOMException;
readonly INDEX_SIZE_ERR: 1;
readonly DOMSTRING_SIZE_ERR: 2;
readonly HIERARCHY_REQUEST_ERR: 3;
readonly WRONG_DOCUMENT_ERR: 4;
readonly INVALID_CHARACTER_ERR: 5;
readonly NO_DATA_ALLOWED_ERR: 6;
readonly NO_MODIFICATION_ALLOWED_ERR: 7;
readonly NOT_FOUND_ERR: 8;
readonly NOT_SUPPORTED_ERR: 9;
readonly INUSE_ATTRIBUTE_ERR: 10;
readonly INVALID_STATE_ERR: 11;
readonly SYNTAX_ERR: 12;
readonly INVALID_MODIFICATION_ERR: 13;
readonly NAMESPACE_ERR: 14;
readonly INVALID_ACCESS_ERR: 15;
readonly VALIDATION_ERR: 16;
readonly TYPE_MISMATCH_ERR: 17;
readonly SECURITY_ERR: 18;
readonly NETWORK_ERR: 19;
readonly ABORT_ERR: 20;
readonly URL_MISMATCH_ERR: 21;
readonly QUOTA_EXCEEDED_ERR: 22;
readonly TIMEOUT_ERR: 23;
readonly INVALID_NODE_TYPE_ERR: 24;
readonly DATA_CLONE_ERR: 25;
}
// #endregion DOMException
declare global {
// Declare "static" methods in Error
interface ErrorConstructor {
@@ -42,6 +156,8 @@ declare global {
interface RequireResolve extends NodeJS.RequireResolve {}
interface NodeModule extends NodeJS.Module {}
var global: typeof globalThis;
var process: NodeJS.Process;
var console: Console;
@@ -54,10 +170,26 @@ declare global {
// Same as module.exports
var exports: any;
interface GCFunction {
(options: {
execution?: "sync";
flavor?: "regular" | "last-resort";
type?: "major-snapshot" | "major" | "minor";
filename?: string;
}): void;
(options: {
execution: "async";
flavor?: "regular" | "last-resort";
type?: "major-snapshot" | "major" | "minor";
filename?: string;
}): Promise<void>;
(options?: boolean): void;
}
/**
* Only available if `--expose-gc` is passed to the process.
*/
var gc: undefined | (() => void);
var gc: undefined | GCFunction;
// #region borrowed
// from https://github.com/microsoft/TypeScript/blob/38da7c600c83e7b31193a62495239a0fe478cb67/lib/lib.webworker.d.ts#L633 until moved to separate lib
@@ -101,52 +233,39 @@ declare global {
};
// #endregion borrowed
// #region Disposable
interface SymbolConstructor {
/**
* A method that is used to release resources held by an object. Called by the semantics of the `using` statement.
*/
readonly dispose: unique symbol;
// #region Storage
/**
* This Web Storage API interface provides access to a particular domain's session or local storage. It allows, for example, the addition, modification, or deletion of stored data items.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage)
*/
interface Storage extends _Storage {}
/**
* A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement.
*/
readonly asyncDispose: unique symbol;
}
// Conditional on `onabort` rather than `onmessage`, in order to exclude lib.webworker
var Storage: typeof globalThis extends { onabort: any; Storage: infer T } ? T
: {
prototype: Storage;
new(): Storage;
};
interface Disposable {
[Symbol.dispose](): void;
}
/**
* A browser-compatible implementation of [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
* Data is stored unencrypted in the file specified by the `--localstorage-file` CLI flag.
* Any modification of this data outside of the Web Storage API is not supported.
* Enable this API with the `--experimental-webstorage` CLI flag.
* @since v22.4.0
*/
var localStorage: Storage;
interface AsyncDisposable {
[Symbol.asyncDispose](): PromiseLike<void>;
}
// #endregion Disposable
// #region ArrayLike.at()
interface RelativeIndexable<T> {
/**
* Takes an integer value and returns the item at that index,
* allowing for positive and negative integers.
* Negative integers count back from the last item in the array.
*/
at(index: number): T | undefined;
}
interface String extends RelativeIndexable<string> {}
interface Array<T> extends RelativeIndexable<T> {}
interface ReadonlyArray<T> extends RelativeIndexable<T> {}
interface Int8Array extends RelativeIndexable<number> {}
interface Uint8Array extends RelativeIndexable<number> {}
interface Uint8ClampedArray extends RelativeIndexable<number> {}
interface Int16Array extends RelativeIndexable<number> {}
interface Uint16Array extends RelativeIndexable<number> {}
interface Int32Array extends RelativeIndexable<number> {}
interface Uint32Array extends RelativeIndexable<number> {}
interface Float32Array extends RelativeIndexable<number> {}
interface Float64Array extends RelativeIndexable<number> {}
interface BigInt64Array extends RelativeIndexable<bigint> {}
interface BigUint64Array extends RelativeIndexable<bigint> {}
// #endregion ArrayLike.at() end
/**
* A browser-compatible implementation of [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage).
* Data is stored in memory, with a storage quota of 10 MB.
* Any modification of this data outside of the Web Storage API is not supported.
* Enable this API with the `--experimental-webstorage` CLI flag.
* @since v22.4.0
*/
var sessionStorage: Storage;
// #endregion Storage
/**
* @since v17.0.0
@@ -158,6 +277,24 @@ declare global {
transfer?: { transfer: ReadonlyArray<import("worker_threads").TransferListItem> },
): T;
// #region DOMException
/**
* @since v17.0.0
* An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
*/
interface DOMException extends _DOMException {}
/**
* @since v17.0.0
*
* The WHATWG `DOMException` class. See [DOMException](https://developer.mozilla.org/docs/Web/API/DOMException) for more details.
*/
var DOMException: typeof globalThis extends { onmessage: any; DOMException: infer T } ? T
: NodeDOMExceptionConstructor;
// #endregion DOMException
/*----------------------------------------------*
* *
* GLOBAL INTERFACES *
@@ -282,7 +419,7 @@ declare global {
unpipe(destination?: WritableStream): this;
unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
wrap(oldStream: ReadableStream): this;
[Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
[Symbol.asyncIterator](): NodeJS.AsyncIterator<string | Buffer>;
}
interface WritableStream extends EventEmitter {
@@ -301,20 +438,6 @@ declare global {
unref(): this;
}
type TypedArray =
| Uint8Array
| Uint8ClampedArray
| Uint16Array
| Uint32Array
| Int8Array
| Int16Array
| Int32Array
| BigUint64Array
| BigInt64Array
| Float32Array
| Float64Array;
type ArrayBufferView = TypedArray | DataView;
interface Require {
(id: string): any;
resolve: RequireResolve;
@@ -365,6 +488,20 @@ declare global {
interface ReadOnlyDict<T> {
readonly [key: string]: T | undefined;
}
/** An iterable iterator returned by the Node.js API. */
// Default TReturn/TNext in v22 is `any`, for compatibility with the previously-used IterableIterator.
// TODO: In next major @types/node version, change default TReturn to undefined.
interface Iterator<T, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
[Symbol.iterator](): NodeJS.Iterator<T, TReturn, TNext>;
}
/** An async iterable iterator returned by the Node.js API. */
// Default TReturn/TNext in v22 is `any`, for compatibility with the previously-used AsyncIterableIterator.
// TODO: In next major @types/node version, change default TReturn to undefined.
interface AsyncIterator<T, TReturn = any, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
[Symbol.asyncIterator](): NodeJS.AsyncIterator<T, TReturn, TNext>;
}
}
interface RequestInit extends _RequestInit {}
@@ -404,14 +541,26 @@ declare global {
} ? T
: typeof import("undici-types").Headers;
interface File extends _File {}
var File: typeof globalThis extends {
interface MessageEvent extends _MessageEvent {}
/**
* @since v15.0.0
*/
var MessageEvent: typeof globalThis extends {
onmessage: any;
File: infer T;
MessageEvent: infer T;
} ? T
: typeof import("node:buffer").File;
: typeof import("undici-types").MessageEvent;
interface WebSocket extends _WebSocket {}
var WebSocket: typeof globalThis extends { onmessage: any; WebSocket: infer T } ? T
: typeof import("undici-types").WebSocket;
interface EventSource extends _EventSource {}
/**
* Only available through the [--experimental-eventsource](https://nodejs.org/api/cli.html#--experimental-eventsource) flag.
*
* @since v22.3.0
*/
var EventSource: typeof globalThis extends { onmessage: any; EventSource: infer T } ? T
: typeof import("undici-types").EventSource;
}

View File

@@ -1 +0,0 @@
declare var global: typeof globalThis;

64
node_modules/@types/node/http.d.ts generated vendored
View File

@@ -1,5 +1,5 @@
/**
* To use the HTTP server and client one must `require('node:http')`.
* To use the HTTP server and client one must import the `node:http` module.
*
* The HTTP interfaces in Node.js are designed to support many features
* of the protocol which have been traditionally difficult to use.
@@ -141,6 +141,7 @@ declare module "http" {
"content-range"?: string | undefined;
"content-security-policy"?: string | undefined;
"content-security-policy-report-only"?: string | undefined;
"content-type"?: string | undefined;
cookie?: string | string[] | undefined;
dav?: string | string[] | undefined;
dnt?: string | undefined;
@@ -231,7 +232,7 @@ declare module "http" {
}
interface ServerOptions<
Request extends typeof IncomingMessage = typeof IncomingMessage,
Response extends typeof ServerResponse = typeof ServerResponse,
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
> {
/**
* Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`.
@@ -315,14 +316,14 @@ declare module "http" {
}
type RequestListener<
Request extends typeof IncomingMessage = typeof IncomingMessage,
Response extends typeof ServerResponse = typeof ServerResponse,
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
> = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
/**
* @since v0.1.17
*/
class Server<
Request extends typeof IncomingMessage = typeof IncomingMessage,
Response extends typeof ServerResponse = typeof ServerResponse,
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
> extends NetServer {
constructor(requestListener?: RequestListener<Request, Response>);
constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
@@ -588,6 +589,42 @@ declare module "http" {
* @param value Header value
*/
setHeader(name: string, value: number | string | readonly string[]): this;
/**
* Sets multiple header values for implicit headers. headers must be an instance of
* `Headers` or `Map`, if a header already exists in the to-be-sent headers, its
* value will be replaced.
*
* ```js
* const headers = new Headers({ foo: 'bar' });
* outgoingMessage.setHeaders(headers);
* ```
*
* or
*
* ```js
* const headers = new Map([['foo', 'bar']]);
* outgoingMessage.setHeaders(headers);
* ```
*
* When headers have been set with `outgoingMessage.setHeaders()`, they will be
* merged with any headers passed to `response.writeHead()`, with the headers passed
* to `response.writeHead()` given precedence.
*
* ```js
* // Returns content-type = text/plain
* const server = http.createServer((req, res) => {
* const headers = new Headers({ 'Content-Type': 'text/html' });
* res.setHeaders(headers);
* res.writeHead(200, { 'Content-Type': 'text/plain' });
* res.end('ok');
* });
* ```
*
* @since v19.6.0, v18.15.0
* @param name Header name
* @param value Header value
*/
setHeaders(headers: Headers | Map<string, number | string | readonly string[]>): this;
/**
* Append a single header value to the header object.
*
@@ -1447,7 +1484,7 @@ declare module "http" {
* To configure any of them, a custom {@link Agent} instance must be created.
*
* ```js
* const http = require('node:http');
* import http from 'node:http';
* const keepAliveAgent = new http.Agent({ keepAlive: true });
* options.agent = keepAliveAgent;
* http.request(options, onResponseCallback)
@@ -1553,11 +1590,11 @@ declare module "http" {
*/
function createServer<
Request extends typeof IncomingMessage = typeof IncomingMessage,
Response extends typeof ServerResponse = typeof ServerResponse,
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
>(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
function createServer<
Request extends typeof IncomingMessage = typeof IncomingMessage,
Response extends typeof ServerResponse = typeof ServerResponse,
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
>(
options: ServerOptions<Request, Response>,
requestListener?: RequestListener<Request, Response>,
@@ -1902,6 +1939,19 @@ declare module "http" {
* Defaults to 16KB. Configurable using the `--max-http-header-size` CLI option.
*/
const maxHeaderSize: number;
/**
* A browser-compatible implementation of [WebSocket](https://nodejs.org/docs/latest/api/http.html#websocket).
* @since v22.5.0
*/
const WebSocket: import("undici-types").WebSocket;
/**
* @since v22.5.0
*/
const CloseEvent: import("undici-types").CloseEvent;
/**
* @since v22.5.0
*/
const MessageEvent: import("undici-types").MessageEvent;
}
declare module "node:http" {
export * from "http";

339
node_modules/@types/node/http2.d.ts generated vendored
View File

@@ -3,7 +3,7 @@
* It can be accessed using:
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* ```
* @since v8.4.0
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/http2.js)
@@ -157,7 +157,7 @@ declare module "http2" {
priority(options: StreamPriorityOptions): void;
/**
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const client = http2.connect('http://example.org:8000');
* const { NGHTTP2_CANCEL } = http2.constants;
* const req = client.request({ ':path': '/' });
@@ -177,7 +177,7 @@ declare module "http2" {
* trailers can be sent.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const server = http2.createServer();
* server.on('stream', (stream) => {
* stream.respond(undefined, { waitForTrailers: true });
@@ -368,7 +368,7 @@ declare module "http2" {
* Initiates a push stream. The callback is invoked with the new `Http2Stream` instance created for the push stream passed as the second argument, or an `Error` passed as the first argument.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const server = http2.createServer();
* server.on('stream', (stream) => {
* stream.respond({ ':status': 200 });
@@ -400,7 +400,7 @@ declare module "http2" {
): void;
/**
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const server = http2.createServer();
* server.on('stream', (stream) => {
* stream.respond({ ':status': 200 });
@@ -408,15 +408,15 @@ declare module "http2" {
* });
* ```
*
* Initiates a response. When the `options.waitForTrailers` option is set, the`'wantTrailers'` event will be emitted immediately after queuing the last chunk
* of payload data to be sent. The `http2stream.sendTrailers()` method can then be
* used to sent trailing header fields to the peer.
* Initiates a response. When the `options.waitForTrailers` option is set, the `'wantTrailers'` event
* will be emitted immediately after queuing the last chunk of payload data to be sent.
* The `http2stream.sendTrailers()` method can then be used to send trailing header fields to the peer.
*
* When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
* close when the final `DATA` frame is transmitted. User code must call either `http2stream.sendTrailers()` or `http2stream.close()` to close the `Http2Stream`.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const server = http2.createServer();
* server.on('stream', (stream) => {
* stream.respond({ ':status': 200 }, { waitForTrailers: true });
@@ -439,8 +439,8 @@ declare module "http2" {
* automatically.
*
* ```js
* const http2 = require('node:http2');
* const fs = require('node:fs');
* import http2 from 'node:http2';
* import fs from 'node:fs';
*
* const server = http2.createServer();
* server.on('stream', (stream) => {
@@ -459,8 +459,8 @@ declare module "http2" {
*
* The optional `options.statCheck` function may be specified to give user code
* an opportunity to set additional content headers based on the `fs.Stat` details
* of the given fd. If the `statCheck` function is provided, the `http2stream.respondWithFD()` method will perform an `fs.fstat()` call to
* collect details on the provided file descriptor.
* of the given fd. If the `statCheck` function is provided, the `http2stream.respondWithFD()` method will
* perform an `fs.fstat()` call to collect details on the provided file descriptor.
*
* The `offset` and `length` options may be used to limit the response to a
* specific range subset. This can be used, for instance, to support HTTP Range
@@ -478,11 +478,12 @@ declare module "http2" {
* header fields to the peer.
*
* When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
* close when the final `DATA` frame is transmitted. User code _must_ call either `http2stream.sendTrailers()` or `http2stream.close()` to close the `Http2Stream`.
* close when the final `DATA` frame is transmitted. User code _must_ call either `http2stream.sendTrailers()`
* or `http2stream.close()` to close the `Http2Stream`.
*
* ```js
* const http2 = require('node:http2');
* const fs = require('node:fs');
* import http2 from 'node:http2';
* import fs from 'node:fs';
*
* const server = http2.createServer();
* server.on('stream', (stream) => {
@@ -521,14 +522,14 @@ declare module "http2" {
* an opportunity to set additional content headers based on the `fs.Stat` details
* of the given file:
*
* If an error occurs while attempting to read the file data, the `Http2Stream` will be closed using an `RST_STREAM` frame using the standard `INTERNAL_ERROR` code. If the `onError` callback is
* defined, then it will be called. Otherwise
* the stream will be destroyed.
* If an error occurs while attempting to read the file data, the `Http2Stream` will be closed using an
* `RST_STREAM` frame using the standard `INTERNAL_ERROR` code.
* If the `onError` callback is defined, then it will be called. Otherwise, the stream will be destroyed.
*
* Example using a file path:
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const server = http2.createServer();
* server.on('stream', (stream) => {
* function statCheck(stat, headers) {
@@ -562,7 +563,7 @@ declare module "http2" {
* results to determine if the file has been modified to return an appropriate `304` response:
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const server = http2.createServer();
* server.on('stream', (stream) => {
* function statCheck(stat, headers) {
@@ -595,7 +596,7 @@ declare module "http2" {
* close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const server = http2.createServer();
* server.on('stream', (stream) => {
* stream.respondWithFile('/some/file',
@@ -677,7 +678,8 @@ declare module "http2" {
*/
readonly encrypted?: boolean | undefined;
/**
* A prototype-less object describing the current local settings of this `Http2Session`. The local settings are local to _this_`Http2Session` instance.
* A prototype-less object describing the current local settings of this `Http2Session`.
* The local settings are local to _this_`Http2Session` instance.
* @since v8.4.0
*/
readonly localSettings: Settings;
@@ -692,12 +694,14 @@ declare module "http2" {
readonly originSet?: string[] | undefined;
/**
* Indicates whether the `Http2Session` is currently waiting for acknowledgment of
* a sent `SETTINGS` frame. Will be `true` after calling the `http2session.settings()` method. Will be `false` once all sent `SETTINGS` frames have been acknowledged.
* a sent `SETTINGS` frame. Will be `true` after calling the `http2session.settings()` method.
* Will be `false` once all sent `SETTINGS` frames have been acknowledged.
* @since v8.4.0
*/
readonly pendingSettingsAck: boolean;
/**
* A prototype-less object describing the current remote settings of this`Http2Session`. The remote settings are set by the _connected_ HTTP/2 peer.
* A prototype-less object describing the current remote settings of this`Http2Session`.
* The remote settings are set by the _connected_ HTTP/2 peer.
* @since v8.4.0
*/
readonly remoteSettings: Settings;
@@ -801,7 +805,7 @@ declare module "http2" {
* the delta.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
*
* const server = http2.createServer();
* const expectedWindowSize = 2 ** 20;
@@ -928,7 +932,7 @@ declare module "http2" {
* This method is only available if `http2session.type` is equal to `http2.constants.NGHTTP2_SESSION_CLIENT`.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const clientSession = http2.connect('https://localhost:1234');
* const {
* HTTP2_HEADER_PATH,
@@ -1048,13 +1052,20 @@ declare module "http2" {
export interface AlternativeServiceOptions {
origin: number | string | url.URL;
}
export interface ServerHttp2Session extends Http2Session {
readonly server: Http2Server | Http2SecureServer;
export interface ServerHttp2Session<
Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
> extends Http2Session {
readonly server:
| Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>
| Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
/**
* Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
*
* const server = http2.createServer();
* server.on('session', (session) => {
@@ -1095,7 +1106,7 @@ declare module "http2" {
* authoritative responses.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const options = getSecureOptionsSomehow();
* const server = http2.createSecureServer(options);
* server.on('stream', (stream) => {
@@ -1121,7 +1132,7 @@ declare module "http2" {
* server using the `http2.createSecureServer()` method:
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const options = getSecureOptionsSomehow();
* options.origins = ['https://example.com', 'https://example.org'];
* const server = http2.createSecureServer(options);
@@ -1144,17 +1155,30 @@ declare module "http2" {
): void;
addListener(
event: "connect",
listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
listener: (
session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
socket: net.Socket | tls.TLSSocket,
) => void,
): this;
addListener(
event: "stream",
listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
): this;
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
emit(event: "connect", session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;
emit(
event: "connect",
session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
socket: net.Socket | tls.TLSSocket,
): boolean;
emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
emit(event: string | symbol, ...args: any[]): boolean;
on(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
on(
event: "connect",
listener: (
session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
socket: net.Socket | tls.TLSSocket,
) => void,
): this;
on(
event: "stream",
listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
@@ -1162,7 +1186,10 @@ declare module "http2" {
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(
event: "connect",
listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
listener: (
session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
socket: net.Socket | tls.TLSSocket,
) => void,
): this;
once(
event: "stream",
@@ -1171,7 +1198,10 @@ declare module "http2" {
once(event: string | symbol, listener: (...args: any[]) => void): this;
prependListener(
event: "connect",
listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
listener: (
session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
socket: net.Socket | tls.TLSSocket,
) => void,
): this;
prependListener(
event: "stream",
@@ -1180,7 +1210,10 @@ declare module "http2" {
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(
event: "connect",
listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
listener: (
session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
socket: net.Socket | tls.TLSSocket,
) => void,
): this;
prependOnceListener(
event: "stream",
@@ -1213,16 +1246,36 @@ declare module "http2" {
createConnection?: ((authority: url.URL, option: SessionOptions) => stream.Duplex) | undefined;
protocol?: "http:" | "https:" | undefined;
}
export interface ServerSessionOptions extends SessionOptions {
Http1IncomingMessage?: typeof IncomingMessage | undefined;
Http1ServerResponse?: typeof ServerResponse | undefined;
Http2ServerRequest?: typeof Http2ServerRequest | undefined;
Http2ServerResponse?: typeof Http2ServerResponse | undefined;
export interface ServerSessionOptions<
Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
> extends SessionOptions {
Http1IncomingMessage?: Http1Request | undefined;
Http1ServerResponse?: Http1Response | undefined;
Http2ServerRequest?: Http2Request | undefined;
Http2ServerResponse?: Http2Response | undefined;
}
export interface SecureClientSessionOptions extends ClientSessionOptions, tls.ConnectionOptions {}
export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsOptions {}
export interface ServerOptions extends ServerSessionOptions {}
export interface SecureServerOptions extends SecureServerSessionOptions {
export interface SecureServerSessionOptions<
Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
> extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response>, tls.TlsOptions {}
export interface ServerOptions<
Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
> extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {}
export interface SecureServerOptions<
Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
> extends SecureServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {
allowHTTP1?: boolean | undefined;
origins?: string[] | undefined;
}
@@ -1234,16 +1287,24 @@ declare module "http2" {
*/
updateSettings(settings: Settings): void;
}
export interface Http2Server extends net.Server, HTTP2ServerCommon {
export interface Http2Server<
Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
> extends net.Server, HTTP2ServerCommon {
addListener(
event: "checkContinue",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
addListener(
event: "request",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
addListener(
event: "session",
listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
): this;
addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
addListener(event: "sessionError", listener: (err: Error) => void): this;
addListener(
event: "stream",
@@ -1251,19 +1312,32 @@ declare module "http2" {
): this;
addListener(event: "timeout", listener: () => void): this;
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
emit(event: "session", session: ServerHttp2Session): boolean;
emit(
event: "checkContinue",
request: InstanceType<Http2Request>,
response: InstanceType<Http2Response>,
): boolean;
emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
emit(
event: "session",
session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
): boolean;
emit(event: "sessionError", err: Error): boolean;
emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
emit(event: "timeout"): boolean;
emit(event: string | symbol, ...args: any[]): boolean;
on(
event: "checkContinue",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
on(
event: "request",
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
on(
event: "session",
listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
): this;
on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
on(event: "session", listener: (session: ServerHttp2Session) => void): this;
on(event: "sessionError", listener: (err: Error) => void): this;
on(
event: "stream",
@@ -1273,10 +1347,16 @@ declare module "http2" {
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(
event: "checkContinue",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
once(
event: "request",
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
once(
event: "session",
listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
): this;
once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
once(event: "session", listener: (session: ServerHttp2Session) => void): this;
once(event: "sessionError", listener: (err: Error) => void): this;
once(
event: "stream",
@@ -1286,13 +1366,16 @@ declare module "http2" {
once(event: string | symbol, listener: (...args: any[]) => void): this;
prependListener(
event: "checkContinue",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
prependListener(
event: "request",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
prependListener(
event: "session",
listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
): this;
prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
prependListener(event: "sessionError", listener: (err: Error) => void): this;
prependListener(
event: "stream",
@@ -1302,13 +1385,16 @@ declare module "http2" {
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(
event: "checkContinue",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
prependOnceListener(
event: "request",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
prependOnceListener(
event: "session",
listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
): this;
prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
prependOnceListener(
event: "stream",
@@ -1317,16 +1403,24 @@ declare module "http2" {
prependOnceListener(event: "timeout", listener: () => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
}
export interface Http2SecureServer extends tls.Server, HTTP2ServerCommon {
export interface Http2SecureServer<
Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
> extends tls.Server, HTTP2ServerCommon {
addListener(
event: "checkContinue",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
addListener(
event: "request",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
addListener(
event: "session",
listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
): this;
addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
addListener(event: "sessionError", listener: (err: Error) => void): this;
addListener(
event: "stream",
@@ -1335,9 +1429,16 @@ declare module "http2" {
addListener(event: "timeout", listener: () => void): this;
addListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
emit(event: "session", session: ServerHttp2Session): boolean;
emit(
event: "checkContinue",
request: InstanceType<Http2Request>,
response: InstanceType<Http2Response>,
): boolean;
emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
emit(
event: "session",
session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
): boolean;
emit(event: "sessionError", err: Error): boolean;
emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
emit(event: "timeout"): boolean;
@@ -1345,10 +1446,16 @@ declare module "http2" {
emit(event: string | symbol, ...args: any[]): boolean;
on(
event: "checkContinue",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
on(
event: "request",
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
on(
event: "session",
listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
): this;
on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
on(event: "session", listener: (session: ServerHttp2Session) => void): this;
on(event: "sessionError", listener: (err: Error) => void): this;
on(
event: "stream",
@@ -1359,10 +1466,16 @@ declare module "http2" {
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(
event: "checkContinue",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
once(
event: "request",
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
once(
event: "session",
listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
): this;
once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
once(event: "session", listener: (session: ServerHttp2Session) => void): this;
once(event: "sessionError", listener: (err: Error) => void): this;
once(
event: "stream",
@@ -1373,13 +1486,16 @@ declare module "http2" {
once(event: string | symbol, listener: (...args: any[]) => void): this;
prependListener(
event: "checkContinue",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
prependListener(
event: "request",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
prependListener(
event: "session",
listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
): this;
prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
prependListener(event: "sessionError", listener: (err: Error) => void): this;
prependListener(
event: "stream",
@@ -1390,13 +1506,16 @@ declare module "http2" {
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(
event: "checkContinue",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
prependOnceListener(
event: "request",
listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): this;
prependOnceListener(
event: "session",
listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
): this;
prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
prependOnceListener(
event: "stream",
@@ -1652,7 +1771,7 @@ declare module "http2" {
* passed as the second parameter to the `'request'` event.
* @since v8.4.0
*/
export class Http2ServerResponse extends stream.Writable {
export class Http2ServerResponse<Request extends Http2ServerRequest = Http2ServerRequest> extends stream.Writable {
constructor(stream: ServerHttp2Stream);
/**
* See `response.socket`.
@@ -1698,7 +1817,7 @@ declare module "http2" {
* A reference to the original HTTP2 `request` object.
* @since v15.7.0
*/
readonly req: Http2ServerRequest;
readonly req: Request;
/**
* Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but
* applies getters, setters, and methods based on HTTP/2 logic.
@@ -1716,7 +1835,7 @@ declare module "http2" {
* All other interactions will be routed directly to the socket.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const server = http2.createServer((req, res) => {
* const ip = req.socket.remoteAddress;
* const port = req.socket.remotePort;
@@ -2292,7 +2411,7 @@ declare module "http2" {
* for use with the `HTTP2-Settings` header field.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
*
* const packed = http2.getPackedSettings({ enablePush: false });
*
@@ -2317,7 +2436,7 @@ declare module "http2" {
* with browser clients.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
*
* // Create an unencrypted HTTP/2 server.
* // Since there are no browsers known that support
@@ -2341,16 +2460,21 @@ declare module "http2" {
export function createServer(
onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
): Http2Server;
export function createServer(
options: ServerOptions,
onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
): Http2Server;
export function createServer<
Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
>(
options: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>;
/**
* Returns a `tls.Server` instance that creates and manages `Http2Session` instances.
*
* ```js
* const http2 = require('node:http2');
* const fs = require('node:fs');
* import http2 from 'node:http2';
* import fs from 'node:fs';
*
* const options = {
* key: fs.readFileSync('server-key.pem'),
@@ -2376,15 +2500,20 @@ declare module "http2" {
export function createSecureServer(
onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
): Http2SecureServer;
export function createSecureServer(
options: SecureServerOptions,
onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
): Http2SecureServer;
export function createSecureServer<
Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
>(
options: SecureServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
): Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
/**
* Returns a `ClientHttp2Session` instance.
*
* ```js
* const http2 = require('node:http2');
* import http2 from 'node:http2';
* const client = http2.connect('https://localhost:1234');
*
* // Use the client
@@ -2411,7 +2540,15 @@ declare module "http2" {
* @param options Any `{@link createServer}` options can be provided.
* @since v20.12.0
*/
export function performServerHandshake(socket: stream.Duplex, options?: ServerOptions): ServerHttp2Session;
export function performServerHandshake<
Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
>(
socket: stream.Duplex,
options?: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
): ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>;
}
declare module "node:http2" {
export * from "http2";

41
node_modules/@types/node/https.d.ts generated vendored
View File

@@ -10,7 +10,7 @@ declare module "https" {
import { URL } from "node:url";
type ServerOptions<
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
> = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
type RequestOptions =
& http.RequestOptions
@@ -21,7 +21,6 @@ declare module "https" {
servername?: string | undefined; // SNI TLS Extension
};
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
rejectUnauthorized?: boolean | undefined;
maxCachedSessions?: number | undefined;
}
/**
@@ -34,7 +33,7 @@ declare module "https" {
}
interface Server<
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
> extends http.Server<Request, Response> {}
/**
* See `http.Server` for more information.
@@ -42,7 +41,7 @@ declare module "https" {
*/
class Server<
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
> extends tls.Server {
constructor(requestListener?: http.RequestListener<Request, Response>);
constructor(
@@ -119,25 +118,19 @@ declare module "https" {
emit(
event: "checkContinue",
req: InstanceType<Request>,
res: InstanceType<Response> & {
req: InstanceType<Request>;
},
res: InstanceType<Response>,
): boolean;
emit(
event: "checkExpectation",
req: InstanceType<Request>,
res: InstanceType<Response> & {
req: InstanceType<Request>;
},
res: InstanceType<Response>,
): boolean;
emit(event: "clientError", err: Error, socket: Duplex): boolean;
emit(event: "connect", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
emit(
event: "request",
req: InstanceType<Request>,
res: InstanceType<Response> & {
req: InstanceType<Request>;
},
res: InstanceType<Response>,
): boolean;
emit(event: "upgrade", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
on(event: string, listener: (...args: any[]) => void): this;
@@ -276,8 +269,8 @@ declare module "https" {
/**
* ```js
* // curl -k https://localhost:8000/
* const https = require('node:https');
* const fs = require('node:fs');
* import https from 'node:https';
* import fs from 'node:fs';
*
* const options = {
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
@@ -293,8 +286,8 @@ declare module "https" {
* Or
*
* ```js
* const https = require('node:https');
* const fs = require('node:fs');
* import https from 'node:https';
* import fs from 'node:fs';
*
* const options = {
* pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
@@ -312,11 +305,11 @@ declare module "https" {
*/
function createServer<
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
>(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
function createServer<
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
>(
options: ServerOptions<Request, Response>,
requestListener?: http.RequestListener<Request, Response>,
@@ -334,7 +327,7 @@ declare module "https" {
* upload a file with a POST request, then write to the `ClientRequest` object.
*
* ```js
* const https = require('node:https');
* import https from 'node:https';
*
* const options = {
* hostname: 'encrypted.google.com',
@@ -407,9 +400,9 @@ declare module "https" {
* Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`):
*
* ```js
* const tls = require('node:tls');
* const https = require('node:https');
* const crypto = require('node:crypto');
* import tls from 'node:tls';
* import https from 'node:https';
* import crypto from 'node:crypto';
*
* function sha256(s) {
* return crypto.createHash('sha256').update(s).digest('base64');
@@ -517,7 +510,7 @@ declare module "https" {
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
*
* ```js
* const https = require('node:https');
* import https from 'node:https';
*
* https.get('https://encrypted.google.com/', (res) => {
* console.log('statusCode:', res.statusCode);

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

@@ -22,18 +22,22 @@
* IN THE SOFTWARE.
*/
// NOTE: These definitions support NodeJS and TypeScript 4.9+.
// NOTE: These definitions support Node.js and TypeScript 5.7+.
// Reference required types from the default lib:
// Reference required TypeScript libs:
/// <reference lib="es2020" />
/// <reference lib="esnext.asynciterable" />
/// <reference lib="esnext.intl" />
/// <reference lib="esnext.bigint" />
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
// TypeScript backwards-compatibility definitions:
/// <reference path="compatibility/index.d.ts" />
// Definitions specific to TypeScript 5.7+:
/// <reference path="globals.typedarray.d.ts" />
/// <reference path="buffer.buffer.d.ts" />
// Definitions for Node.js modules that are not specific to any version of TypeScript:
/// <reference path="globals.d.ts" />
/// <reference path="assert.d.ts" />
/// <reference path="assert/strict.d.ts" />
/// <reference path="globals.d.ts" />
/// <reference path="async_hooks.d.ts" />
/// <reference path="buffer.d.ts" />
/// <reference path="child_process.d.ts" />
@@ -67,6 +71,7 @@
/// <reference path="readline/promises.d.ts" />
/// <reference path="repl.d.ts" />
/// <reference path="sea.d.ts" />
/// <reference path="sqlite.d.ts" />
/// <reference path="stream.d.ts" />
/// <reference path="stream/promises.d.ts" />
/// <reference path="stream/consumers.d.ts" />
@@ -85,5 +90,3 @@
/// <reference path="wasi.d.ts" />
/// <reference path="worker_threads.d.ts" />
/// <reference path="zlib.d.ts" />
/// <reference path="globals.global.d.ts" />

1440
node_modules/@types/node/inspector.d.ts generated vendored

File diff suppressed because it is too large Load Diff

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

@@ -12,9 +12,9 @@ declare module "module" {
* does not add or remove exported names from the `ES Modules`.
*
* ```js
* const fs = require('node:fs');
* const assert = require('node:assert');
* const { syncBuiltinESMExports } = require('node:module');
* import fs from 'node:fs';
* import assert from 'node:assert';
* import { syncBuiltinESMExports } from 'node:module';
*
* fs.readFile = newAPI;
*
@@ -48,7 +48,7 @@ declare module "module" {
* @since v13.7.0, v12.17.0
* @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise.
*/
function findSourceMap(path: string, error?: Error): SourceMap;
function findSourceMap(path: string, error?: Error): SourceMap | undefined;
interface SourceMapPayload {
file: string;
version: number;
@@ -238,12 +238,66 @@ declare module "module" {
context: LoadHookContext,
nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput | Promise<LoadFnOutput>,
) => LoadFnOutput | Promise<LoadFnOutput>;
namespace constants {
/**
* The following constants are returned as the `status` field in the object returned by
* {@link enableCompileCache} to indicate the result of the attempt to enable the
* [module compile cache](https://nodejs.org/docs/latest-v22.x/api/module.html#module-compile-cache).
* @since v22.8.0
*/
namespace compileCacheStatus {
/**
* Node.js has enabled the compile cache successfully. The directory used to store the
* compile cache will be returned in the `directory` field in the
* returned object.
*/
const ENABLED: number;
/**
* The compile cache has already been enabled before, either by a previous call to
* {@link enableCompileCache}, or by the `NODE_COMPILE_CACHE=dir`
* environment variable. The directory used to store the
* compile cache will be returned in the `directory` field in the
* returned object.
*/
const ALREADY_ENABLED: number;
/**
* Node.js fails to enable the compile cache. This can be caused by the lack of
* permission to use the specified directory, or various kinds of file system errors.
* The detail of the failure will be returned in the `message` field in the
* returned object.
*/
const FAILED: number;
/**
* Node.js cannot enable the compile cache because the environment variable
* `NODE_DISABLE_COMPILE_CACHE=1` has been set.
*/
const DISABLED: number;
}
}
}
interface RegisterOptions<Data> {
parentURL: string | URL;
data?: Data | undefined;
transferList?: any[] | undefined;
}
interface EnableCompileCacheResult {
/**
* One of the {@link constants.compileCacheStatus}
*/
status: number;
/**
* If Node.js cannot enable the compile cache, this contains
* the error message. Only set if `status` is `module.constants.compileCacheStatus.FAILED`.
*/
message?: string;
/**
* If the compile cache is enabled, this contains the directory
* where the compile cache is stored. Only set if `status` is
* `module.constants.compileCacheStatus.ENABLED` or
* `module.constants.compileCacheStatus.ALREADY_ENABLED`.
*/
directory?: string;
}
interface Module extends NodeModule {}
class Module {
static runMain(): void;
@@ -258,6 +312,43 @@ declare module "module" {
options?: RegisterOptions<Data>,
): void;
static register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
/**
* Enable [module compile cache](https://nodejs.org/docs/latest-v22.x/api/module.html#module-compile-cache)
* in the current Node.js instance.
*
* If `cacheDir` is not specified, Node.js will either use the directory specified by the
* `NODE_COMPILE_CACHE=dir` environment variable if it's set, or use
* `path.join(os.tmpdir(), 'node-compile-cache')` otherwise. For general use cases, it's
* recommended to call `module.enableCompileCache()` without specifying the `cacheDir`,
* so that the directory can be overridden by the `NODE_COMPILE_CACHE` environment
* variable when necessary.
*
* Since compile cache is supposed to be a quiet optimization that is not required for the
* application to be functional, this method is designed to not throw any exception when the
* compile cache cannot be enabled. Instead, it will return an object containing an error
* message in the `message` field to aid debugging.
* If compile cache is enabled successfully, the `directory` field in the returned object
* contains the path to the directory where the compile cache is stored. The `status`
* field in the returned object would be one of the `module.constants.compileCacheStatus`
* values to indicate the result of the attempt to enable the
* [module compile cache](https://nodejs.org/docs/latest-v22.x/api/module.html#module-compile-cache).
*
* This method only affects the current Node.js instance. To enable it in child worker threads,
* either call this method in child worker threads too, or set the
* `process.env.NODE_COMPILE_CACHE` value to compile cache directory so the behavior can
* be inherited into the child workers. The directory can be obtained either from the
* `directory` field returned by this method, or with {@link getCompileCacheDir}.
* @since v22.8.0
* @param cacheDir Optional path to specify the directory where the compile cache
* will be stored/retrieved.
*/
static enableCompileCache(cacheDir?: string): EnableCompileCacheResult;
/**
* @since v22.8.0
* @return Path to the [module compile cache](https://nodejs.org/docs/latest-v22.x/api/module.html#module-compile-cache)
* directory if it is enabled, or `undefined` otherwise.
*/
static getCompileCacheDir(): string | undefined;
constructor(id: string, parent?: Module);
}
global {

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

@@ -8,7 +8,7 @@
* It can be accessed using:
*
* ```js
* const net = require('node:net');
* import net from 'node:net';
* ```
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/net.js)
*/
@@ -29,6 +29,7 @@ declare module "net" {
interface SocketConstructorOpts {
fd?: number | undefined;
allowHalfOpen?: boolean | undefined;
onread?: OnReadOpts | undefined;
readable?: boolean | undefined;
writable?: boolean | undefined;
signal?: AbortSignal;
@@ -37,20 +38,15 @@ declare module "net" {
buffer: Uint8Array | (() => Uint8Array);
/**
* This function is called for every chunk of incoming data.
* Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer.
* Return false from this function to implicitly pause() the socket.
* Two arguments are passed to it: the number of bytes written to `buffer` and a reference to `buffer`.
* Return `false` from this function to implicitly `pause()` the socket.
*/
callback(bytesWritten: number, buf: Uint8Array): boolean;
callback(bytesWritten: number, buffer: Uint8Array): boolean;
}
interface ConnectOpts {
/**
* If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
* Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
* still be emitted as normal and methods like pause() and resume() will also behave as expected.
*/
onread?: OnReadOpts | undefined;
}
interface TcpSocketConnectOpts extends ConnectOpts {
// TODO: remove empty ConnectOpts placeholder at next major @types/node version.
/** @deprecated */
interface ConnectOpts {}
interface TcpSocketConnectOpts {
port: number;
host?: string | undefined;
localAddress?: string | undefined;
@@ -70,7 +66,7 @@ declare module "net" {
*/
autoSelectFamilyAttemptTimeout?: number | undefined;
}
interface IpcSocketConnectOpts extends ConnectOpts {
interface IpcSocketConnectOpts {
path: string;
}
type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
@@ -532,6 +528,12 @@ declare module "net" {
* @since v16.5.0
*/
keepAliveInitialDelay?: number | undefined;
/**
* Optionally overrides all `net.Socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
* @default See [stream.getDefaultHighWaterMark()](https://nodejs.org/docs/latest-v22.x/api/stream.html#streamgetdefaulthighwatermarkobjectmode).
* @since v18.17.0, v20.1.0
*/
highWaterMark?: number | undefined;
}
interface DropArgument {
localAddress?: string;
@@ -812,7 +814,7 @@ declare module "net" {
* on port 8124:
*
* ```js
* const net = require('node:net');
* import net from 'node:net';
* const server = net.createServer((c) => {
* // 'connection' listener.
* console.log('client connected');

2
node_modules/@types/node/os.d.ts generated vendored
View File

@@ -3,7 +3,7 @@
* properties. It can be accessed using:
*
* ```js
* const os = require('node:os');
* import os from 'node:os';
* ```
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/os.js)
*/

View File

@@ -1,6 +1,6 @@
{
"name": "@types/node",
"version": "22.2.0",
"version": "22.9.3",
"description": "TypeScript definitions for node",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
"license": "MIT",
@@ -203,6 +203,13 @@
],
"main": "",
"types": "index.d.ts",
"typesVersions": {
"<=5.6": {
"*": [
"ts5.6/*"
]
}
},
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
@@ -210,8 +217,9 @@
},
"scripts": {},
"dependencies": {
"undici-types": "~6.13.0"
"undici-types": "~6.19.8"
},
"typesPublisherContentHash": "e8a1feecc621a4e4c40517dba1262b6a77dcb9cdd874f74c76cb391931926c7c",
"typeScriptVersion": "4.8"
"peerDependencies": {},
"typesPublisherContentHash": "b6aac29bd05fd45bf1e413969174cab33920f03b086f10916dba01864e150462",
"typeScriptVersion": "4.9"
}

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

@@ -11,7 +11,7 @@ declare module "path/win32" {
* paths. It can be accessed using:
*
* ```js
* const path = require('node:path');
* import path from 'node:path';
* ```
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/path.js)
*/
@@ -94,6 +94,15 @@ declare module "path" {
* @throws {TypeError} if any of the arguments is not a string.
*/
resolve(...paths: string[]): string;
/**
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
* @param path The path to glob-match against.
* @param pattern The glob to check the path against.
* @returns Whether or not the `path` matched the `pattern`.
* @throws {TypeError} if `path` or `pattern` are not strings.
* @since v22.5.0
*/
matchesGlob(path: string, pattern: string): boolean;
/**
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
*

View File

@@ -10,7 +10,7 @@
* * [Resource Timing](https://www.w3.org/TR/resource-timing-2/)
*
* ```js
* const { PerformanceObserver, performance } = require('node:perf_hooks');
* import { PerformanceObserver, performance } from 'node:perf_hooks';
*
* const obs = new PerformanceObserver((items) => {
* console.log(items.getEntries()[0].duration);
@@ -116,6 +116,20 @@ declare module "perf_hooks" {
class PerformanceMeasure extends PerformanceEntry {
readonly entryType: "measure";
}
interface UVMetrics {
/**
* Number of event loop iterations.
*/
readonly loopCount: number;
/**
* Number of events that have been processed by the event handler.
*/
readonly events: number;
/**
* Number of events that were waiting to be processed when the event provider was called.
*/
readonly eventsWaiting: number;
}
/**
* _This property is an extension by Node.js. It is not available in Web browsers._
*
@@ -166,6 +180,16 @@ declare module "perf_hooks" {
* @since v8.5.0
*/
readonly nodeStart: number;
/**
* This is a wrapper to the `uv_metrics_info` function.
* It returns the current set of event loop metrics.
*
* It is recommended to use this property inside a function whose execution was
* scheduled using `setImmediate` to avoid collecting metrics before finishing all
* operations scheduled during the current loop iteration.
* @since v22.8.0, v20.18.0
*/
readonly uvMetricsInfo: UVMetrics;
/**
* The high resolution millisecond timestamp at which the V8 platform was
* initialized.
@@ -355,10 +379,10 @@ declare module "perf_hooks" {
* A `PerformanceObserver` must be subscribed to the `'function'` event type in order for the timing details to be accessed.
*
* ```js
* const {
* import {
* performance,
* PerformanceObserver,
* } = require('node:perf_hooks');
* } from 'node:perf_hooks';
*
* function someFunction() {
* console.log('hello world');
@@ -397,10 +421,10 @@ declare module "perf_hooks" {
* with respect to `performanceEntry.startTime`.
*
* ```js
* const {
* import {
* performance,
* PerformanceObserver,
* } = require('node:perf_hooks');
* } from 'node:perf_hooks';
*
* const obs = new PerformanceObserver((perfObserverList, observer) => {
* console.log(perfObserverList.getEntries());
@@ -440,10 +464,10 @@ declare module "perf_hooks" {
* equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to`type`.
*
* ```js
* const {
* import {
* performance,
* PerformanceObserver,
* } = require('node:perf_hooks');
* } from 'node:perf_hooks';
*
* const obs = new PerformanceObserver((perfObserverList, observer) => {
* console.log(perfObserverList.getEntriesByName('meow'));
@@ -491,10 +515,10 @@ declare module "perf_hooks" {
* with respect to `performanceEntry.startTime` whose `performanceEntry.entryType` is equal to `type`.
*
* ```js
* const {
* import {
* performance,
* PerformanceObserver,
* } = require('node:perf_hooks');
* } from 'node:perf_hooks';
*
* const obs = new PerformanceObserver((perfObserverList, observer) => {
* console.log(perfObserverList.getEntriesByType('mark'));
@@ -544,10 +568,10 @@ declare module "perf_hooks" {
* Subscribes the `PerformanceObserver` instance to notifications of new `PerformanceEntry` instances identified either by `options.entryTypes` or `options.type`:
*
* ```js
* const {
* import {
* performance,
* PerformanceObserver,
* } = require('node:perf_hooks');
* } from 'node:perf_hooks';
*
* const obs = new PerformanceObserver((list, observer) => {
* // Called once asynchronously. `list` contains three items.
@@ -816,7 +840,7 @@ declare module "perf_hooks" {
* detect.
*
* ```js
* const { monitorEventLoopDelay } = require('node:perf_hooks');
* import { monitorEventLoopDelay } from 'node:perf_hooks';
* const h = monitorEventLoopDelay({ resolution: 20 });
* h.enable();
* // Do something.
@@ -865,7 +889,7 @@ declare module "perf_hooks" {
} from "perf_hooks";
global {
/**
* `PerformanceEntry` is a global reference for `require('node:perf_hooks').PerformanceEntry`
* `PerformanceEntry` is a global reference for `import { PerformanceEntry } from 'node:perf_hooks'`
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performanceentry
* @since v19.0.0
*/
@@ -875,7 +899,7 @@ declare module "perf_hooks" {
} ? T
: typeof _PerformanceEntry;
/**
* `PerformanceMark` is a global reference for `require('node:perf_hooks').PerformanceMark`
* `PerformanceMark` is a global reference for `import { PerformanceMark } from 'node:perf_hooks'`
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performancemark
* @since v19.0.0
*/
@@ -885,7 +909,7 @@ declare module "perf_hooks" {
} ? T
: typeof _PerformanceMark;
/**
* `PerformanceMeasure` is a global reference for `require('node:perf_hooks').PerformanceMeasure`
* `PerformanceMeasure` is a global reference for `import { PerformanceMeasure } from 'node:perf_hooks'`
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performancemeasure
* @since v19.0.0
*/
@@ -895,7 +919,7 @@ declare module "perf_hooks" {
} ? T
: typeof _PerformanceMeasure;
/**
* `PerformanceObserver` is a global reference for `require('node:perf_hooks').PerformanceObserver`
* `PerformanceObserver` is a global reference for `import { PerformanceObserver } from 'node:perf_hooks'`
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performanceobserver
* @since v19.0.0
*/
@@ -905,7 +929,7 @@ declare module "perf_hooks" {
} ? T
: typeof _PerformanceObserver;
/**
* `PerformanceObserverEntryList` is a global reference for `require('node:perf_hooks').PerformanceObserverEntryList`
* `PerformanceObserverEntryList` is a global reference for `import { PerformanceObserverEntryList } from 'node:perf_hooks'`
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performanceobserverentrylist
* @since v19.0.0
*/
@@ -915,7 +939,7 @@ declare module "perf_hooks" {
} ? T
: typeof _PerformanceObserverEntryList;
/**
* `PerformanceResourceTiming` is a global reference for `require('node:perf_hooks').PerformanceResourceTiming`
* `PerformanceResourceTiming` is a global reference for `import { PerformanceResourceTiming } from 'node:perf_hooks'`
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performanceresourcetiming
* @since v19.0.0
*/
@@ -925,7 +949,7 @@ declare module "perf_hooks" {
} ? T
: typeof _PerformanceResourceTiming;
/**
* `performance` is a global reference for `require('node:perf_hooks').performance`
* `performance` is a global reference for `import { performance } from 'node:perf_hooks'`
* @see https://nodejs.org/docs/latest-v22.x/api/globals.html#performance
* @since v16.0.0
*/

192
node_modules/@types/node/process.d.ts generated vendored
View File

@@ -1,8 +1,121 @@
declare module "process" {
import * as net from "node:net";
import * as os from "node:os";
import * as tty from "node:tty";
import { Worker } from "node:worker_threads";
interface BuiltInModule {
"assert": typeof import("assert");
"node:assert": typeof import("node:assert");
"assert/strict": typeof import("assert/strict");
"node:assert/strict": typeof import("node:assert/strict");
"async_hooks": typeof import("async_hooks");
"node:async_hooks": typeof import("node:async_hooks");
"buffer": typeof import("buffer");
"node:buffer": typeof import("node:buffer");
"child_process": typeof import("child_process");
"node:child_process": typeof import("node:child_process");
"cluster": typeof import("cluster");
"node:cluster": typeof import("node:cluster");
"console": typeof import("console");
"node:console": typeof import("node:console");
"constants": typeof import("constants");
"node:constants": typeof import("node:constants");
"crypto": typeof import("crypto");
"node:crypto": typeof import("node:crypto");
"dgram": typeof import("dgram");
"node:dgram": typeof import("node:dgram");
"diagnostics_channel": typeof import("diagnostics_channel");
"node:diagnostics_channel": typeof import("node:diagnostics_channel");
"dns": typeof import("dns");
"node:dns": typeof import("node:dns");
"dns/promises": typeof import("dns/promises");
"node:dns/promises": typeof import("node:dns/promises");
"domain": typeof import("domain");
"node:domain": typeof import("node:domain");
"events": typeof import("events");
"node:events": typeof import("node:events");
"fs": typeof import("fs");
"node:fs": typeof import("node:fs");
"fs/promises": typeof import("fs/promises");
"node:fs/promises": typeof import("node:fs/promises");
"http": typeof import("http");
"node:http": typeof import("node:http");
"http2": typeof import("http2");
"node:http2": typeof import("node:http2");
"https": typeof import("https");
"node:https": typeof import("node:https");
"inspector": typeof import("inspector");
"node:inspector": typeof import("node:inspector");
"inspector/promises": typeof import("inspector/promises");
"node:inspector/promises": typeof import("node:inspector/promises");
"module": typeof import("module");
"node:module": typeof import("node:module");
"net": typeof import("net");
"node:net": typeof import("node:net");
"os": typeof import("os");
"node:os": typeof import("node:os");
"path": typeof import("path");
"node:path": typeof import("node:path");
"path/posix": typeof import("path/posix");
"node:path/posix": typeof import("node:path/posix");
"path/win32": typeof import("path/win32");
"node:path/win32": typeof import("node:path/win32");
"perf_hooks": typeof import("perf_hooks");
"node:perf_hooks": typeof import("node:perf_hooks");
"process": typeof import("process");
"node:process": typeof import("node:process");
"punycode": typeof import("punycode");
"node:punycode": typeof import("node:punycode");
"querystring": typeof import("querystring");
"node:querystring": typeof import("node:querystring");
"readline": typeof import("readline");
"node:readline": typeof import("node:readline");
"readline/promises": typeof import("readline/promises");
"node:readline/promises": typeof import("node:readline/promises");
"repl": typeof import("repl");
"node:repl": typeof import("node:repl");
"node:sea": typeof import("node:sea");
"node:sqlite": typeof import("node:sqlite");
"stream": typeof import("stream");
"node:stream": typeof import("node:stream");
"stream/consumers": typeof import("stream/consumers");
"node:stream/consumers": typeof import("node:stream/consumers");
"stream/promises": typeof import("stream/promises");
"node:stream/promises": typeof import("node:stream/promises");
"stream/web": typeof import("stream/web");
"node:stream/web": typeof import("node:stream/web");
"string_decoder": typeof import("string_decoder");
"node:string_decoder": typeof import("node:string_decoder");
"node:test": typeof import("node:test");
"node:test/reporters": typeof import("node:test/reporters");
"timers": typeof import("timers");
"node:timers": typeof import("node:timers");
"timers/promises": typeof import("timers/promises");
"node:timers/promises": typeof import("node:timers/promises");
"tls": typeof import("tls");
"node:tls": typeof import("node:tls");
"trace_events": typeof import("trace_events");
"node:trace_events": typeof import("node:trace_events");
"tty": typeof import("tty");
"node:tty": typeof import("node:tty");
"url": typeof import("url");
"node:url": typeof import("node:url");
"util": typeof import("util");
"node:util": typeof import("node:util");
"sys": typeof import("util");
"node:sys": typeof import("node:util");
"util/types": typeof import("util/types");
"node:util/types": typeof import("node:util/types");
"v8": typeof import("v8");
"node:v8": typeof import("node:v8");
"vm": typeof import("vm");
"node:vm": typeof import("node:vm");
"wasi": typeof import("wasi");
"node:wasi": typeof import("node:wasi");
"worker_threads": typeof import("worker_threads");
"node:worker_threads": typeof import("node:worker_threads");
"zlib": typeof import("zlib");
"node:zlib": typeof import("node:zlib");
}
global {
var process: NodeJS.Process;
namespace NodeJS {
@@ -209,24 +322,28 @@ declare module "process" {
has(scope: string, reference?: string): boolean;
}
interface ProcessReport {
/**
* Write reports in a compact format, single-line JSON, more easily consumable by log processing systems
* than the default multi-line format designed for human consumption.
* @since v13.12.0, v12.17.0
*/
compact: boolean;
/**
* Directory where the report is written.
* The default value is the empty string, indicating that reports are written to the current
* working directory of the Node.js process.
* @default '' indicating that reports are written to the current
*/
directory: string;
/**
* Filename where the report is written.
* The default value is the empty string.
* @default '' the output filename will be comprised of a timestamp,
* PID, and sequence number.
* Filename where the report is written. If set to the empty string, the output filename will be comprised
* of a timestamp, PID, and sequence number. The default value is the empty string.
*/
filename: string;
/**
* Returns a JSON-formatted diagnostic report for the running process.
* The report's JavaScript stack trace is taken from err, if present.
* Returns a JavaScript Object representation of a diagnostic report for the running process.
* The report's JavaScript stack trace is taken from `err`, if present.
*/
getReport(err?: Error): string;
getReport(err?: Error): object;
/**
* If true, a diagnostic report is generated on fatal errors,
* such as out of memory errors or failed C++ assertions.
@@ -252,18 +369,19 @@ declare module "process" {
/**
* Writes a diagnostic report to a file. If filename is not provided, the default filename
* includes the date, time, PID, and a sequence number.
* The report's JavaScript stack trace is taken from err, if present.
* The report's JavaScript stack trace is taken from `err`, if present.
*
* If the value of filename is set to `'stdout'` or `'stderr'`, the report is written
* to the stdout or stderr of the process respectively.
* @param fileName Name of the file where the report is written.
* This should be a relative path, that will be appended to the directory specified in
* `process.report.directory`, or the current working directory of the Node.js process,
* if unspecified.
* @param error A custom error used for reporting the JavaScript stack.
* @param err A custom error used for reporting the JavaScript stack.
* @return Filename of the generated report.
*/
writeReport(fileName?: string): string;
writeReport(error?: Error): string;
writeReport(fileName?: string, err?: Error): string;
writeReport(err?: Error): string;
}
interface ResourceUsage {
fsRead: number;
@@ -775,6 +893,40 @@ declare module "process" {
* @since v0.11.8
*/
exitCode?: number | string | number | undefined;
finalization: {
/**
* This function registers a callback to be called when the process emits the `exit` event if the `ref` object was not garbage collected.
* If the object `ref` was garbage collected before the `exit` event is emitted, the callback will be removed from the finalization registry, and it will not be called on process exit.
*
* Inside the callback you can release the resources allocated by the `ref` object.
* Be aware that all limitations applied to the `beforeExit` event are also applied to the callback function,
* this means that there is a possibility that the callback will not be called under special circumstances.
*
* The idea of this function is to help you free up resources when the starts process exiting, but also let the object be garbage collected if it is no longer being used.
* @param ref The reference to the resource that is being tracked.
* @param callback The callback function to be called when the resource is finalized.
* @since v22.5.0
* @experimental
*/
register<T extends object>(ref: T, callback: (ref: T, event: "exit") => void): void;
/**
* This function behaves exactly like the `register`, except that the callback will be called when the process emits the `beforeExit` event if `ref` object was not garbage collected.
*
* Be aware that all limitations applied to the `beforeExit` event are also applied to the callback function, this means that there is a possibility that the callback will not be called under special circumstances.
* @param ref The reference to the resource that is being tracked.
* @param callback The callback function to be called when the resource is finalized.
* @since v22.5.0
* @experimental
*/
registerBeforeExit<T extends object>(ref: T, callback: (ref: T, event: "beforeExit") => void): void;
/**
* This function remove the register of the object from the finalization registry, so the callback will not be called anymore.
* @param ref The reference to the resource that was registered previously.
* @since v22.5.0
* @experimental
*/
unregister(ref: object): void;
};
/**
* The `process.getActiveResourcesInfo()` method returns an array of strings containing
* the types of the active resources that are currently keeping the event loop alive.
@@ -793,6 +945,12 @@ declare module "process" {
* @since v17.3.0, v16.14.0
*/
getActiveResourcesInfo(): string[];
/**
* Provides a way to load built-in modules in a globally available function.
* @param id ID of the built-in module being requested.
*/
getBuiltinModule<ID extends keyof BuiltInModule>(id: ID): BuiltInModule[ID];
getBuiltinModule(id: string): object | undefined;
/**
* The `process.getgid()` method returns the numerical group identity of the
* process. (See [`getgid(2)`](http://man7.org/linux/man-pages/man2/getgid.2.html).)
@@ -1585,11 +1743,11 @@ declare module "process" {
*/
allowedNodeEnvironmentFlags: ReadonlySet<string>;
/**
* `process.report` is an object whose methods are used to generate diagnostic
* reports for the current process. Additional documentation is available in the `report documentation`.
* `process.report` is an object whose methods are used to generate diagnostic reports for the current process.
* Additional documentation is available in the [report documentation](https://nodejs.org/docs/latest-v22.x/api/report.html).
* @since v11.8.0
*/
report?: ProcessReport | undefined;
report: ProcessReport;
/**
* ```js
* import { resourceUsage } from 'node:process';

View File

@@ -8,7 +8,7 @@
* can be accessed using:
*
* ```js
* const punycode = require('punycode');
* import punycode from 'node:punycode';
* ```
*
* [Punycode](https://tools.ietf.org/html/rfc3492) is a character encoding scheme defined by RFC 3492 that is

View File

@@ -3,7 +3,7 @@
* query strings. It can be accessed using:
*
* ```js
* const querystring = require('node:querystring');
* import querystring from 'node:querystring';
* ```
*
* `querystring` is more performant than `URLSearchParams` but is not a

View File

@@ -304,7 +304,7 @@ declare module "readline" {
prependOnceListener(event: "SIGINT", listener: () => void): this;
prependOnceListener(event: "SIGTSTP", listener: () => void): this;
prependOnceListener(event: "history", listener: (history: string[]) => void): this;
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
[Symbol.asyncIterator](): NodeJS.AsyncIterator<string>;
}
export type ReadLine = Interface; // type forwarded for backwards compatibility
export type Completer = (line: string) => CompleterResult;
@@ -314,35 +314,84 @@ declare module "readline" {
) => void;
export type CompleterResult = [string[], string];
export interface ReadLineOptions {
/**
* The [`Readable`](https://nodejs.org/docs/latest-v22.x/api/stream.html#readable-streams) stream to listen to
*/
input: NodeJS.ReadableStream;
/**
* The [`Writable`](https://nodejs.org/docs/latest-v22.x/api/stream.html#writable-streams) stream to write readline data to.
*/
output?: NodeJS.WritableStream | undefined;
/**
* An optional function used for Tab autocompletion.
*/
completer?: Completer | AsyncCompleter | undefined;
/**
* `true` if the `input` and `output` streams should be treated like a TTY,
* and have ANSI/VT100 escape codes written to it.
* Default: checking `isTTY` on the `output` stream upon instantiation.
*/
terminal?: boolean | undefined;
/**
* Initial list of history lines. This option makes sense
* only if `terminal` is set to `true` by the user or by an internal `output`
* check, otherwise the history caching mechanism is not initialized at all.
* Initial list of history lines.
* This option makes sense only if `terminal` is set to `true` by the user or by an internal `output` check,
* otherwise the history caching mechanism is not initialized at all.
* @default []
*/
history?: string[] | undefined;
historySize?: number | undefined;
prompt?: string | undefined;
crlfDelay?: number | undefined;
/**
* If `true`, when a new input line added
* to the history list duplicates an older one, this removes the older line
* from the list.
* Maximum number of history lines retained.
* To disable the history set this value to `0`.
* This option makes sense only if `terminal` is set to `true` by the user or by an internal `output` check,
* otherwise the history caching mechanism is not initialized at all.
* @default 30
*/
historySize?: number | undefined;
/**
* If `true`, when a new input line added to the history list duplicates an older one,
* this removes the older line from the list.
* @default false
*/
removeHistoryDuplicates?: boolean | undefined;
/**
* The prompt string to use.
* @default "> "
*/
prompt?: string | undefined;
/**
* If the delay between `\r` and `\n` exceeds `crlfDelay` milliseconds,
* both `\r` and `\n` will be treated as separate end-of-line input.
* `crlfDelay` will be coerced to a number no less than `100`.
* It can be set to `Infinity`, in which case
* `\r` followed by `\n` will always be considered a single newline
* (which may be reasonable for [reading files](https://nodejs.org/docs/latest-v22.x/api/readline.html#example-read-file-stream-line-by-line) with `\r\n` line delimiter).
* @default 100
*/
crlfDelay?: number | undefined;
/**
* The duration `readline` will wait for a character
* (when reading an ambiguous key sequence in milliseconds
* one that can both form a complete key sequence using the input read so far
* and can take additional input to complete a longer key sequence).
* @default 500
*/
escapeCodeTimeout?: number | undefined;
/**
* The number of spaces a tab is equal to (minimum 1).
* @default 8
*/
tabSize?: number | undefined;
/**
* Allows closing the interface using an AbortSignal.
* Aborting the signal will internally call `close` on the interface.
*/
signal?: AbortSignal | undefined;
}
/**
* The `readline.createInterface()` method creates a new `readline.Interface` instance.
*
* ```js
* const readline = require('node:readline');
* import readline from 'node:readline';
* const rl = readline.createInterface({
* input: process.stdin,
* output: process.stdout,
@@ -398,7 +447,7 @@ declare module "readline" {
* implement a small command-line interface:
*
* ```js
* const readline = require('node:readline');
* import readline from 'node:readline';
* const rl = readline.createInterface({
* input: process.stdin,
* output: process.stdout,
@@ -430,8 +479,8 @@ declare module "readline" {
* well as a `for await...of` loop:
*
* ```js
* const fs = require('node:fs');
* const readline = require('node:readline');
* import fs from 'node:fs';
* import readline from 'node:readline';
*
* async function processLineByLine() {
* const fileStream = fs.createReadStream('input.txt');
@@ -455,8 +504,8 @@ declare module "readline" {
* Alternatively, one could use the `'line'` event:
*
* ```js
* const fs = require('node:fs');
* const readline = require('node:readline');
* import fs from 'node:fs';
* import readline from 'node:readline';
*
* const rl = readline.createInterface({
* input: fs.createReadStream('sample.txt'),
@@ -471,9 +520,9 @@ declare module "readline" {
* Currently, `for await...of` loop can be a bit slower. If `async` / `await` flow and speed are both essential, a mixed approach can be applied:
*
* ```js
* const { once } = require('node:events');
* const { createReadStream } = require('node:fs');
* const { createInterface } = require('node:readline');
* import { once } from 'node:events';
* import { createReadStream } from 'node:fs';
* import { createInterface } from 'node:readline';
*
* (async function processLineByLine() {
* try {

View File

@@ -3,8 +3,13 @@
* @experimental
*/
declare module "readline/promises" {
import { AsyncCompleter, Completer, Direction, Interface as _Interface, ReadLineOptions } from "node:readline";
import { Abortable } from "node:events";
import {
CompleterResult,
Direction,
Interface as _Interface,
ReadLineOptions as _ReadLineOptions,
} from "node:readline";
/**
* Instances of the `readlinePromises.Interface` class are constructed using the `readlinePromises.createInterface()` method. Every instance is associated with a
* single `input` `Readable` stream and a single `output` `Writable` stream.
@@ -111,11 +116,18 @@ declare module "readline/promises" {
*/
rollback(): this;
}
type Completer = (line: string) => CompleterResult | Promise<CompleterResult>;
interface ReadLineOptions extends Omit<_ReadLineOptions, "completer"> {
/**
* An optional function used for Tab autocompletion.
*/
completer?: Completer | undefined;
}
/**
* The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface` instance.
*
* ```js
* const readlinePromises = require('node:readline/promises');
* import readlinePromises from 'node:readline/promises';
* const rl = readlinePromises.createInterface({
* input: process.stdin,
* output: process.stdout,
@@ -140,7 +152,7 @@ declare module "readline/promises" {
function createInterface(
input: NodeJS.ReadableStream,
output?: NodeJS.WritableStream,
completer?: Completer | AsyncCompleter,
completer?: Completer,
terminal?: boolean,
): Interface;
function createInterface(options: ReadLineOptions): Interface;

8
node_modules/@types/node/repl.d.ts generated vendored
View File

@@ -4,7 +4,7 @@
* applications. It can be accessed using:
*
* ```js
* const repl = require('node:repl');
* import repl from 'node:repl';
* ```
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/repl.js)
*/
@@ -130,7 +130,7 @@ declare module "repl" {
* or directly using the JavaScript `new` keyword.
*
* ```js
* const repl = require('node:repl');
* import repl from 'node:repl';
*
* const options = { useColors: true };
*
@@ -257,7 +257,7 @@ declare module "repl" {
* The following example shows two new commands added to the REPL instance:
*
* ```js
* const repl = require('node:repl');
* import repl from 'node:repl';
*
* const replServer = repl.start({ prompt: '> ' });
* replServer.defineCommand('sayhello', {
@@ -407,7 +407,7 @@ declare module "repl" {
* If `options` is a string, then it specifies the input prompt:
*
* ```js
* const repl = require('node:repl');
* import repl from 'node:repl';
*
* // a Unix style prompt
* repl.start('$ ');

53
node_modules/@types/node/stream.d.ts generated vendored
View File

@@ -10,7 +10,7 @@
* To access the `node:stream` module:
*
* ```js
* const stream = require('node:stream');
* import stream from 'node:stream';
* ```
*
* The `node:stream` module is useful for creating new types of stream instances.
@@ -303,7 +303,7 @@ declare module "stream" {
* the method does nothing.
*
* ```js
* const fs = require('node:fs');
* import fs from 'node:fs';
* const readable = getReadableStreamSomehow();
* const writable = fs.createWriteStream('file.txt');
* // All the data from readable goes into 'file.txt',
@@ -341,7 +341,7 @@ declare module "stream" {
* // Pull off a header delimited by \n\n.
* // Use unshift() if we get too much.
* // Call the callback with (error, header, stream).
* const { StringDecoder } = require('node:string_decoder');
* import { StringDecoder } from 'node:string_decoder';
* function parseHeader(stream, callback) {
* stream.on('error', callback);
* stream.on('readable', onReadable);
@@ -399,8 +399,8 @@ declare module "stream" {
* libraries.
*
* ```js
* const { OldReader } = require('./old-api-module.js');
* const { Readable } = require('node:stream');
* import { OldReader } from './old-api-module.js';
* import { Readable } from 'node:stream';
* const oreader = new OldReader();
* const myReader = new Readable().wrap(oreader);
*
@@ -422,7 +422,7 @@ declare module "stream" {
* or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream.
* **Default: `true`**.
*/
iterator(options?: { destroyOnReturn?: boolean }): AsyncIterableIterator<any>;
iterator(options?: { destroyOnReturn?: boolean }): NodeJS.AsyncIterator<any>;
/**
* This method allows mapping over the stream. The *fn* function will be called for every chunk in the stream.
* If the *fn* function returns a promise - that promise will be `await`ed before being passed to the result stream.
@@ -651,7 +651,7 @@ declare module "stream" {
removeListener(event: "readable", listener: () => void): this;
removeListener(event: "resume", listener: () => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
[Symbol.asyncIterator](): AsyncIterableIterator<any>;
[Symbol.asyncIterator](): NodeJS.AsyncIterator<any>;
/**
* Calls `readable.destroy()` with an `AbortError` and returns a promise that fulfills when the stream is finished.
* @since v20.4.0
@@ -806,7 +806,7 @@ declare module "stream" {
*
* ```js
* // Write 'hello, ' and then end with 'world!'.
* const fs = require('node:fs');
* import fs from 'node:fs';
* const file = fs.createWriteStream('example.txt');
* file.write('hello, ');
* file.end('world!');
@@ -1250,6 +1250,25 @@ declare module "stream" {
removeListener(event: "unpipe", listener: (src: Readable) => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
}
/**
* The utility function `duplexPair` returns an Array with two items,
* each being a `Duplex` stream connected to the other side:
*
* ```js
* const [ sideA, sideB ] = duplexPair();
* ```
*
* Whatever is written to one stream is made readable on the other. It provides
* behavior analogous to a network connection, where the data written by the client
* becomes readable by the server, and vice-versa.
*
* The Duplex streams are symmetrical; one or the other may be used without any
* difference in behavior.
* @param options A value to pass to both {@link Duplex} constructors,
* to set options such as buffering.
* @since v22.6.0
*/
function duplexPair(options?: DuplexOptions): [Duplex, Duplex];
type TransformCallback = (error?: Error | null, data?: any) => void;
interface TransformOptions extends DuplexOptions {
construct?(this: Transform, callback: (error?: Error | null) => void): void;
@@ -1304,7 +1323,7 @@ declare module "stream" {
* stream, and `controller.error(new AbortError())` for webstreams.
*
* ```js
* const fs = require('node:fs');
* import fs from 'node:fs';
*
* const controller = new AbortController();
* const read = addAbortSignal(
@@ -1398,8 +1417,8 @@ declare module "stream" {
* or has experienced an error or a premature close event.
*
* ```js
* const { finished } = require('node:stream');
* const fs = require('node:fs');
* import { finished } from 'node:stream';
* import fs from 'node:fs';
*
* const rs = fs.createReadStream('archive.tar');
*
@@ -1482,9 +1501,9 @@ declare module "stream" {
* properly cleaning up and provide a callback when the pipeline is complete.
*
* ```js
* const { pipeline } = require('node:stream');
* const fs = require('node:fs');
* const zlib = require('node:zlib');
* import { pipeline } from 'node:stream';
* import fs from 'node:fs';
* import zlib from 'node:zlib';
*
* // Use the pipeline API to easily pipe a series of streams
* // together and get notified when the pipeline is fully done.
@@ -1524,9 +1543,9 @@ declare module "stream" {
* See the example below:
*
* ```js
* const fs = require('node:fs');
* const http = require('node:http');
* const { pipeline } = require('node:stream');
* import fs from 'node:fs';
* import http from 'node:http';
* import { pipeline } from 'node:stream';
*
* const server = http.createServer((req, res) => {
* const fileStream = fs.createReadStream('./fileNotExist.txt');

View File

@@ -1,12 +1,19 @@
declare module "stream/promises" {
import {
FinishedOptions,
FinishedOptions as _FinishedOptions,
PipelineDestination,
PipelineOptions,
PipelinePromise,
PipelineSource,
PipelineTransform,
} from "node:stream";
interface FinishedOptions extends _FinishedOptions {
/**
* If true, removes the listeners registered by this function before the promise is fulfilled.
* @default false
*/
cleanup?: boolean | undefined;
}
function finished(
stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream,
options?: FinishedOptions,

View File

@@ -1,3 +1,38 @@
type _ByteLengthQueuingStrategy = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").ByteLengthQueuingStrategy;
type _CompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {}
: import("stream/web").CompressionStream;
type _CountQueuingStrategy = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").CountQueuingStrategy;
type _DecompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {}
: import("stream/web").DecompressionStream;
type _ReadableByteStreamController = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").ReadableByteStreamController;
type _ReadableStream<R = any> = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").ReadableStream<R>;
type _ReadableStreamBYOBReader = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").ReadableStreamBYOBReader;
type _ReadableStreamBYOBRequest = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").ReadableStreamBYOBRequest;
type _ReadableStreamDefaultController<R = any> = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").ReadableStreamDefaultController<R>;
type _ReadableStreamDefaultReader<R = any> = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").ReadableStreamDefaultReader<R>;
type _TextDecoderStream = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").TextDecoderStream;
type _TextEncoderStream = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").TextEncoderStream;
type _TransformStream<I = any, O = any> = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").TransformStream<I, O>;
type _TransformStreamDefaultController<O = any> = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").TransformStreamDefaultController<O>;
type _WritableStream<W = any> = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").WritableStream<W>;
type _WritableStreamDefaultController = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").WritableStreamDefaultController;
type _WritableStreamDefaultWriter<W = any> = typeof globalThis extends { onmessage: any } ? {}
: import("stream/web").WritableStreamDefaultWriter<W>;
declare module "stream/web" {
// stub module, pending copy&paste from .d.ts or manual impl
// copy from lib.dom.d.ts
@@ -65,18 +100,7 @@ declare module "stream/web" {
readonly closed: Promise<undefined>;
cancel(reason?: any): Promise<void>;
}
interface ReadableStreamDefaultReadValueResult<T> {
done: false;
value: T;
}
interface ReadableStreamDefaultReadDoneResult {
done: true;
value?: undefined;
}
type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
type ReadableStreamDefaultReadResult<T> =
| ReadableStreamDefaultReadValueResult<T>
| ReadableStreamDefaultReadDoneResult;
interface ReadableStreamReadValueResult<T> {
done: false;
value: T;
@@ -142,17 +166,21 @@ declare module "stream/web" {
interface ReadableStreamErrorCallback {
(reason: any): void | PromiseLike<void>;
}
interface ReadableStreamAsyncIterator<T> extends NodeJS.AsyncIterator<T, NodeJS.BuiltinIteratorReturn, unknown> {
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<T>;
}
/** This Streams API interface represents a readable stream of byte data. */
interface ReadableStream<R = any> {
readonly locked: boolean;
cancel(reason?: any): Promise<void>;
getReader(): ReadableStreamDefaultReader<R>;
getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
getReader(): ReadableStreamDefaultReader<R>;
getReader(options?: ReadableStreamGetReaderOptions): ReadableStreamReader<R>;
pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
tee(): [ReadableStream<R>, ReadableStream<R>];
values(options?: { preventCancel?: boolean }): AsyncIterableIterator<R>;
[Symbol.asyncIterator](): AsyncIterableIterator<R>;
values(options?: { preventCancel?: boolean }): ReadableStreamAsyncIterator<R>;
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<R>;
}
const ReadableStream: {
prototype: ReadableStream;
@@ -160,20 +188,48 @@ declare module "stream/web" {
new(underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
new<R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
};
type ReadableStreamReaderMode = "byob";
interface ReadableStreamGetReaderOptions {
/**
* Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
*
* This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.
*/
mode?: ReadableStreamReaderMode;
}
type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBYOBReader;
interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
read(): Promise<ReadableStreamDefaultReadResult<R>>;
read(): Promise<ReadableStreamReadResult<R>>;
releaseLock(): void;
}
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */
interface ReadableStreamBYOBReader extends ReadableStreamGenericReader {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */
read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */
releaseLock(): void;
}
const ReadableStreamDefaultReader: {
prototype: ReadableStreamDefaultReader;
new<R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
};
const ReadableStreamBYOBReader: any;
const ReadableStreamBYOBRequest: any;
const ReadableStreamBYOBReader: {
prototype: ReadableStreamBYOBReader;
new(stream: ReadableStream): ReadableStreamBYOBReader;
};
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) */
interface ReadableStreamBYOBRequest {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) */
readonly view: ArrayBufferView | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) */
respond(bytesWritten: number): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) */
respondWithNewView(view: ArrayBufferView): void;
}
const ReadableStreamBYOBRequest: {
prototype: ReadableStreamBYOBRequest;
new(): ReadableStreamBYOBRequest;
};
interface ReadableByteStreamController {
readonly byobRequest: undefined;
readonly desiredSize: number | null;
@@ -345,22 +401,208 @@ declare module "stream/web" {
prototype: TextDecoderStream;
new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream;
};
interface CompressionStream<R = any, W = any> {
readonly readable: ReadableStream<R>;
readonly writable: WritableStream<W>;
interface CompressionStream {
readonly readable: ReadableStream;
readonly writable: WritableStream;
}
const CompressionStream: {
prototype: CompressionStream;
new<R = any, W = any>(format: "deflate" | "deflate-raw" | "gzip"): CompressionStream<R, W>;
new(format: "deflate" | "deflate-raw" | "gzip"): CompressionStream;
};
interface DecompressionStream<R = any, W = any> {
readonly readable: ReadableStream<R>;
readonly writable: WritableStream<W>;
interface DecompressionStream {
readonly writable: WritableStream;
readonly readable: ReadableStream;
}
const DecompressionStream: {
prototype: DecompressionStream;
new<R = any, W = any>(format: "deflate" | "deflate-raw" | "gzip"): DecompressionStream<R, W>;
new(format: "deflate" | "deflate-raw" | "gzip"): DecompressionStream;
};
global {
interface ByteLengthQueuingStrategy extends _ByteLengthQueuingStrategy {}
/**
* `ByteLengthQueuingStrategy` class is a global reference for `import { ByteLengthQueuingStrategy } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-bytelengthqueuingstrategy
* @since v18.0.0
*/
var ByteLengthQueuingStrategy: typeof globalThis extends { onmessage: any; ByteLengthQueuingStrategy: infer T }
? T
: typeof import("stream/web").ByteLengthQueuingStrategy;
interface CompressionStream extends _CompressionStream {}
/**
* `CompressionStream` class is a global reference for `import { CompressionStream } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-compressionstream
* @since v18.0.0
*/
var CompressionStream: typeof globalThis extends {
onmessage: any;
// CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit.
// If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts
ReportingObserver: any;
CompressionStream: infer T;
} ? T
// TS 4.8, 4.9, 5.0
: typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? {
prototype: T;
new(format: "deflate" | "deflate-raw" | "gzip"): T;
}
: typeof import("stream/web").CompressionStream;
interface CountQueuingStrategy extends _CountQueuingStrategy {}
/**
* `CountQueuingStrategy` class is a global reference for `import { CountQueuingStrategy } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-countqueuingstrategy
* @since v18.0.0
*/
var CountQueuingStrategy: typeof globalThis extends { onmessage: any; CountQueuingStrategy: infer T } ? T
: typeof import("stream/web").CountQueuingStrategy;
interface DecompressionStream extends _DecompressionStream {}
/**
* `DecompressionStream` class is a global reference for `import { DecompressionStream } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-decompressionstream
* @since v18.0.0
*/
var DecompressionStream: typeof globalThis extends {
onmessage: any;
// CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit.
// If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts
ReportingObserver: any;
DecompressionStream: infer T extends object;
} ? T
// TS 4.8, 4.9, 5.0
: typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? {
prototype: T;
new(format: "deflate" | "deflate-raw" | "gzip"): T;
}
: typeof import("stream/web").DecompressionStream;
interface ReadableByteStreamController extends _ReadableByteStreamController {}
/**
* `ReadableByteStreamController` class is a global reference for `import { ReadableByteStreamController } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-readablebytestreamcontroller
* @since v18.0.0
*/
var ReadableByteStreamController: typeof globalThis extends
{ onmessage: any; ReadableByteStreamController: infer T } ? T
: typeof import("stream/web").ReadableByteStreamController;
interface ReadableStream<R = any> extends _ReadableStream<R> {}
/**
* `ReadableStream` class is a global reference for `import { ReadableStream } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-readablestream
* @since v18.0.0
*/
var ReadableStream: typeof globalThis extends { onmessage: any; ReadableStream: infer T } ? T
: typeof import("stream/web").ReadableStream;
interface ReadableStreamBYOBReader extends _ReadableStreamBYOBReader {}
/**
* `ReadableStreamBYOBReader` class is a global reference for `import { ReadableStreamBYOBReader } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-readablestreambyobreader
* @since v18.0.0
*/
var ReadableStreamBYOBReader: typeof globalThis extends { onmessage: any; ReadableStreamBYOBReader: infer T }
? T
: typeof import("stream/web").ReadableStreamBYOBReader;
interface ReadableStreamBYOBRequest extends _ReadableStreamBYOBRequest {}
/**
* `ReadableStreamBYOBRequest` class is a global reference for `import { ReadableStreamBYOBRequest } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-readablestreambyobrequest
* @since v18.0.0
*/
var ReadableStreamBYOBRequest: typeof globalThis extends { onmessage: any; ReadableStreamBYOBRequest: infer T }
? T
: typeof import("stream/web").ReadableStreamBYOBRequest;
interface ReadableStreamDefaultController<R = any> extends _ReadableStreamDefaultController<R> {}
/**
* `ReadableStreamDefaultController` class is a global reference for `import { ReadableStreamDefaultController } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-readablestreamdefaultcontroller
* @since v18.0.0
*/
var ReadableStreamDefaultController: typeof globalThis extends
{ onmessage: any; ReadableStreamDefaultController: infer T } ? T
: typeof import("stream/web").ReadableStreamDefaultController;
interface ReadableStreamDefaultReader<R = any> extends _ReadableStreamDefaultReader<R> {}
/**
* `ReadableStreamDefaultReader` class is a global reference for `import { ReadableStreamDefaultReader } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-readablestreamdefaultreader
* @since v18.0.0
*/
var ReadableStreamDefaultReader: typeof globalThis extends
{ onmessage: any; ReadableStreamDefaultReader: infer T } ? T
: typeof import("stream/web").ReadableStreamDefaultReader;
interface TextDecoderStream extends _TextDecoderStream {}
/**
* `TextDecoderStream` class is a global reference for `import { TextDecoderStream } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-textdecoderstream
* @since v18.0.0
*/
var TextDecoderStream: typeof globalThis extends { onmessage: any; TextDecoderStream: infer T } ? T
: typeof import("stream/web").TextDecoderStream;
interface TextEncoderStream extends _TextEncoderStream {}
/**
* `TextEncoderStream` class is a global reference for `import { TextEncoderStream } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-textencoderstream
* @since v18.0.0
*/
var TextEncoderStream: typeof globalThis extends { onmessage: any; TextEncoderStream: infer T } ? T
: typeof import("stream/web").TextEncoderStream;
interface TransformStream<I = any, O = any> extends _TransformStream<I, O> {}
/**
* `TransformStream` class is a global reference for `import { TransformStream } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-transformstream
* @since v18.0.0
*/
var TransformStream: typeof globalThis extends { onmessage: any; TransformStream: infer T } ? T
: typeof import("stream/web").TransformStream;
interface TransformStreamDefaultController<O = any> extends _TransformStreamDefaultController<O> {}
/**
* `TransformStreamDefaultController` class is a global reference for `import { TransformStreamDefaultController } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-transformstreamdefaultcontroller
* @since v18.0.0
*/
var TransformStreamDefaultController: typeof globalThis extends
{ onmessage: any; TransformStreamDefaultController: infer T } ? T
: typeof import("stream/web").TransformStreamDefaultController;
interface WritableStream<W = any> extends _WritableStream<W> {}
/**
* `WritableStream` class is a global reference for `import { WritableStream } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-writablestream
* @since v18.0.0
*/
var WritableStream: typeof globalThis extends { onmessage: any; WritableStream: infer T } ? T
: typeof import("stream/web").WritableStream;
interface WritableStreamDefaultController extends _WritableStreamDefaultController {}
/**
* `WritableStreamDefaultController` class is a global reference for `import { WritableStreamDefaultController } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-writablestreamdefaultcontroller
* @since v18.0.0
*/
var WritableStreamDefaultController: typeof globalThis extends
{ onmessage: any; WritableStreamDefaultController: infer T } ? T
: typeof import("stream/web").WritableStreamDefaultController;
interface WritableStreamDefaultWriter<W = any> extends _WritableStreamDefaultWriter<W> {}
/**
* `WritableStreamDefaultWriter` class is a global reference for `import { WritableStreamDefaultWriter } from 'node:stream/web'`.
* https://nodejs.org/api/globals.html#class-writablestreamdefaultwriter
* @since v18.0.0
*/
var WritableStreamDefaultWriter: typeof globalThis extends
{ onmessage: any; WritableStreamDefaultWriter: infer T } ? T
: typeof import("stream/web").WritableStreamDefaultWriter;
}
}
declare module "node:stream/web" {
export * from "stream/web";

View File

@@ -4,13 +4,13 @@
* characters. It can be accessed using:
*
* ```js
* const { StringDecoder } = require('node:string_decoder');
* import { StringDecoder } from 'node:string_decoder';
* ```
*
* The following example shows the basic use of the `StringDecoder` class.
*
* ```js
* const { StringDecoder } = require('node:string_decoder');
* import { StringDecoder } from 'node:string_decoder';
* const decoder = new StringDecoder('utf8');
*
* const cent = Buffer.from([0xC2, 0xA2]);
@@ -29,7 +29,7 @@
* symbol (`€`) are written over three separate operations:
*
* ```js
* const { StringDecoder } = require('node:string_decoder');
* import { StringDecoder } from 'node:string_decoder';
* const decoder = new StringDecoder('utf8');
*
* decoder.write(Buffer.from([0xE2]));

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

@@ -10,7 +10,7 @@
* work:
*
* ```js
* import test from 'test';
* import test from 'node:test';
* ```
*
* Tests created via the `test` module consist of a single function that is
@@ -144,7 +144,22 @@ declare module "node:test" {
function test(options?: TestOptions, fn?: TestFn): Promise<void>;
function test(fn?: TestFn): Promise<void>;
namespace test {
export { after, afterEach, before, beforeEach, describe, it, mock, only, run, skip, suite, test, todo };
export {
after,
afterEach,
before,
beforeEach,
describe,
it,
mock,
only,
run,
skip,
snapshot,
suite,
test,
todo,
};
}
/**
* The `suite()` function is imported from the `node:test` module.
@@ -316,13 +331,31 @@ declare module "node:test" {
* @default false
*/
forceExit?: boolean | undefined;
/**
* An array containing the list of glob patterns to match test files.
* This option cannot be used together with `files`. If omitted, files are run according to the
* [test runner execution model](https://nodejs.org/docs/latest-v22.x/api/test.html#test-runner-execution-model).
* @since v22.6.0
*/
globPatterns?: readonly string[] | undefined;
/**
* Sets inspector port of test child process.
* If a nullish value is provided, each process gets its own port,
* incremented from the primary's `process.debugPort`.
* This can be a number, or a function that takes no arguments and returns a
* number. If a nullish value is provided, each process gets its own port,
* incremented from the primary's `process.debugPort`. This option is ignored
* if the `isolation` option is set to `'none'` as no child processes are
* spawned.
* @default undefined
*/
inspectPort?: number | (() => number) | undefined;
/**
* Configures the type of test isolation. If set to
* `'process'`, each test file is run in a separate child process. If set to
* `'none'`, all test files run in the current process.
* @default 'process'
* @since v22.8.0
*/
isolation?: "process" | "none" | undefined;
/**
* If truthy, the test context will only run tests that have the `only` option set
*/
@@ -464,37 +497,41 @@ declare module "node:test" {
/**
* An object containing assertion methods bound to the test context.
* The top-level functions from the `node:assert` module are exposed here for the purpose of creating test plans.
* @since v22.2.0
* @since v22.2.0, v20.15.0
*/
readonly assert: TestContextAssert;
/**
* This function is used to create a hook running before subtest of the current test.
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
* @param fn The hook function. The first argument to this function is a `TestContext` object.
* If the hook uses callbacks, the callback function is passed as the second argument.
* @param options Configuration options for the hook.
* @since v20.1.0
* @since v20.1.0, v18.17.0
*/
before: typeof before;
before(fn?: TestContextHookFn, options?: HookOptions): void;
/**
* This function is used to create a hook running before each subtest of the current test.
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
* @param fn The hook function. The first argument to this function is a `TestContext` object.
* If the hook uses callbacks, the callback function is passed as the second argument.
* @param options Configuration options for the hook.
* @since v18.8.0
*/
beforeEach: typeof beforeEach;
beforeEach(fn?: TestContextHookFn, options?: HookOptions): void;
/**
* This function is used to create a hook that runs after the current test finishes.
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
* @param fn The hook function. The first argument to this function is a `TestContext` object.
* If the hook uses callbacks, the callback function is passed as the second argument.
* @param options Configuration options for the hook.
* @since v18.13.0
*/
after: typeof after;
after(fn?: TestContextHookFn, options?: HookOptions): void;
/**
* This function is used to create a hook running after each subtest of the current test.
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
* @param fn The hook function. The first argument to this function is a `TestContext` object.
* If the hook uses callbacks, the callback function is passed as the second argument.
* @param options Configuration options for the hook.
* @since v18.8.0
*/
afterEach: typeof afterEach;
afterEach(fn?: TestContextHookFn, options?: HookOptions): void;
/**
* This function is used to write diagnostics to the output. Any diagnostic
* information is included at the end of the test's results. This function does
@@ -509,6 +546,17 @@ declare module "node:test" {
* @param message Message to be reported.
*/
diagnostic(message: string): void;
/**
* The absolute path of the test file that created the current test. If a test file imports
* additional modules that generate tests, the imported tests will return the path of the root test file.
* @since v22.6.0
*/
readonly filePath: string | undefined;
/**
* The name of the test and each of its ancestors, separated by `>`.
* @since v22.3.0
*/
readonly fullName: string;
/**
* The name of the test.
* @since v18.8.0, v16.18.0
@@ -633,6 +681,22 @@ declare module "node:test" {
deepEqual: typeof import("node:assert").deepEqual;
/**
* Identical to the `deepStrictEqual` function from the `node:assert` module, but bound to the test context.
*
* **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
* type annotation, otherwise an error will be raised by the TypeScript compiler:
* ```ts
* import { test, type TestContext } from 'node:test';
*
* // The test function's context parameter must have a type annotation.
* test('example', (t: TestContext) => {
* t.assert.deepStrictEqual(actual, expected);
* });
*
* // Omitting the type annotation will result in a compilation error.
* test('example', t => {
* t.assert.deepStrictEqual(actual, expected); // Error: 't' needs an explicit type annotation.
* });
* ```
*/
deepStrictEqual: typeof import("node:assert").deepStrictEqual;
/**
@@ -657,6 +721,22 @@ declare module "node:test" {
fail: typeof import("node:assert").fail;
/**
* Identical to the `ifError` function from the `node:assert` module, but bound to the test context.
*
* **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
* type annotation, otherwise an error will be raised by the TypeScript compiler:
* ```ts
* import { test, type TestContext } from 'node:test';
*
* // The test function's context parameter must have a type annotation.
* test('example', (t: TestContext) => {
* t.assert.ifError(err);
* });
*
* // Omitting the type annotation will result in a compilation error.
* test('example', t => {
* t.assert.ifError(err); // Error: 't' needs an explicit type annotation.
* });
* ```
*/
ifError: typeof import("node:assert").ifError;
/**
@@ -681,6 +761,22 @@ declare module "node:test" {
notStrictEqual: typeof import("node:assert").notStrictEqual;
/**
* Identical to the `ok` function from the `node:assert` module, but bound to the test context.
*
* **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
* type annotation, otherwise an error will be raised by the TypeScript compiler:
* ```ts
* import { test, type TestContext } from 'node:test';
*
* // The test function's context parameter must have a type annotation.
* test('example', (t: TestContext) => {
* t.assert.ok(condition);
* });
*
* // Omitting the type annotation will result in a compilation error.
* test('example', t => {
* t.assert.ok(condition)); // Error: 't' needs an explicit type annotation.
* });
* ```
*/
ok: typeof import("node:assert").ok;
/**
@@ -689,12 +785,58 @@ declare module "node:test" {
rejects: typeof import("node:assert").rejects;
/**
* Identical to the `strictEqual` function from the `node:assert` module, but bound to the test context.
*
* **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
* type annotation, otherwise an error will be raised by the TypeScript compiler:
* ```ts
* import { test, type TestContext } from 'node:test';
*
* // The test function's context parameter must have a type annotation.
* test('example', (t: TestContext) => {
* t.assert.strictEqual(actual, expected);
* });
*
* // Omitting the type annotation will result in a compilation error.
* test('example', t => {
* t.assert.strictEqual(actual, expected); // Error: 't' needs an explicit type annotation.
* });
* ```
*/
strictEqual: typeof import("node:assert").strictEqual;
/**
* Identical to the `throws` function from the `node:assert` module, but bound to the test context.
*/
throws: typeof import("node:assert").throws;
/**
* This function implements assertions for snapshot testing.
* ```js
* test('snapshot test with default serialization', (t) => {
* t.assert.snapshot({ value1: 1, value2: 2 });
* });
*
* test('snapshot test with custom serialization', (t) => {
* t.assert.snapshot({ value3: 3, value4: 4 }, {
* serializers: [(value) => JSON.stringify(value)]
* });
* });
* ```
*
* Only available through the [--experimental-test-snapshots](https://nodejs.org/api/cli.html#--experimental-test-snapshots) flag.
* @since v22.3.0
* @experimental
*/
snapshot(value: any, options?: AssertSnapshotOptions): void;
}
interface AssertSnapshotOptions {
/**
* An array of synchronous functions used to serialize `value` into a string.
* `value` is passed as the only argument to the first serializer function.
* The return value of each serializer is passed as input to the next serializer.
* Once all serializers have run, the resulting value is coerced to a string.
*
* If no serializers are provided, the test runner's default serializers are used.
*/
serializers?: ReadonlyArray<(value: any) => any> | undefined;
}
/**
@@ -704,6 +846,12 @@ declare module "node:test" {
* @since v18.7.0, v16.17.0
*/
class SuiteContext {
/**
* The absolute path of the test file that created the current suite. If a test file imports
* additional modules that generate suites, the imported suites will return the path of the root test file.
* @since v22.6.0
*/
readonly filePath: string | undefined;
/**
* The name of the suite.
* @since v18.8.0, v16.18.0
@@ -830,10 +978,15 @@ declare module "node:test" {
*/
function afterEach(fn?: HookFn, options?: HookOptions): void;
/**
* The hook function. If the hook uses callbacks, the callback function is passed as the
* second argument.
* The hook function. The first argument is the context in which the hook is called.
* If the hook uses callbacks, the callback function is passed as the second argument.
*/
type HookFn = (s: SuiteContext, done: (result?: any) => void) => any;
type HookFn = (c: TestContext | SuiteContext, done: (result?: any) => void) => any;
/**
* The hook function. The first argument is a `TestContext` object.
* If the hook uses callbacks, the callback function is passed as the second argument.
*/
type TestContextHookFn = (t: TestContext, done: (result?: any) => void) => any;
/**
* Configuration options for hooks.
* @since v18.8.0
@@ -879,6 +1032,30 @@ declare module "node:test" {
type FunctionPropertyNames<T> = {
[K in keyof T]: T[K] extends Function ? K : never;
}[keyof T];
interface MockModuleOptions {
/**
* If false, each call to `require()` or `import()` generates a new mock module.
* If true, subsequent calls will return the same module mock, and the mock module is inserted into the CommonJS cache.
* @default false
*/
cache?: boolean | undefined;
/**
* The value to use as the mocked module's default export.
*
* If this value is not provided, ESM mocks do not include a default export.
* If the mock is a CommonJS or builtin module, this setting is used as the value of `module.exports`.
* If this value is not provided, CJS and builtin mocks use an empty object as the value of `module.exports`.
*/
defaultExport?: any;
/**
* An object whose keys and values are used to create the named exports of the mock module.
*
* If the mock is a CommonJS or builtin module, these values are copied onto `module.exports`.
* Therefore, if a mock is created with both named exports and a non-object default export,
* the mock will throw an exception when used as a CJS or builtin module.
*/
namedExports?: object | undefined;
}
/**
* The `MockTracker` class is used to manage mocking functionality. The test runner
* module provides a top level `mock` export which is a `MockTracker` instance.
@@ -1042,6 +1219,18 @@ declare module "node:test" {
options?: MockFunctionOptions,
): Mock<((value: MockedObject[MethodName]) => void) | Implementation>;
/**
* This function is used to mock the exports of ECMAScript modules, CommonJS modules, and Node.js builtin modules.
* Any references to the original module prior to mocking are not impacted.
*
* Only available through the [--experimental-test-module-mocks](https://nodejs.org/api/cli.html#--experimental-test-module-mocks) flag.
* @since v22.3.0
* @experimental
* @param specifier A string identifying the module to mock.
* @param options Optional configuration options for the mock module.
*/
module(specifier: string, options?: MockModuleOptions): MockModuleContext;
/**
* This function restores the default behavior of all mocks that were previously
* created by this `MockTracker` and disassociates the mocks from the `MockTracker` instance. Once disassociated, the mocks can still be used, but the `MockTracker` instance can no longer be
@@ -1201,6 +1390,17 @@ declare module "node:test" {
*/
restore(): void;
}
/**
* @since v22.3.0
* @experimental
*/
class MockModuleContext {
/**
* Resets the implementation of the mock module.
* @since v22.3.0
*/
restore(): void;
}
type Timer = "setInterval" | "setTimeout" | "setImmediate" | "Date";
interface MockTimersOptions {
@@ -1423,6 +1623,36 @@ declare module "node:test" {
*/
[Symbol.dispose](): void;
}
/**
* Only available through the [--experimental-test-snapshots](https://nodejs.org/api/cli.html#--experimental-test-snapshots) flag.
* @since v22.3.0
* @experimental
*/
namespace snapshot {
/**
* This function is used to customize the default serialization mechanism used by the test runner.
*
* By default, the test runner performs serialization by calling `JSON.stringify(value, null, 2)` on the provided value.
* `JSON.stringify()` does have limitations regarding circular structures and supported data types.
* If a more robust serialization mechanism is required, this function should be used to specify a list of custom serializers.
*
* Serializers are called in order, with the output of the previous serializer passed as input to the next.
* The final result must be a string value.
* @since v22.3.0
* @param serializers An array of synchronous functions used as the default serializers for snapshot tests.
*/
function setDefaultSnapshotSerializers(serializers: ReadonlyArray<(value: any) => any>): void;
/**
* This function is used to set a custom resolver for the location of the snapshot file used for snapshot testing.
* By default, the snapshot filename is the same as the entry point filename with `.snapshot` appended.
* @since v22.3.0
* @param fn A function used to compute the location of the snapshot file.
* The function receives the path of the test file as its only argument. If the
* test is not associated with a file (for example in the REPL), the input is
* undefined. `fn()` must return a string specifying the location of the snapshot file.
*/
function setResolveSnapshotPath(fn: (path: string | undefined) => string): void;
}
export {
after,
afterEach,
@@ -1435,6 +1665,7 @@ declare module "node:test" {
only,
run,
skip,
snapshot,
suite,
SuiteContext,
test,
@@ -1565,6 +1796,25 @@ interface TestCoverage {
count: number;
}>;
}>;
/**
* An object containing whether or not the coverage for
* each coverage type.
* @since v22.9.0
*/
thresholds: {
/**
* The function coverage threshold.
*/
function: number;
/**
* The branch coverage threshold.
*/
branch: number;
/**
* The line coverage threshold.
*/
line: number;
};
/**
* An object containing a summary of coverage for all files.
*/
@@ -1810,7 +2060,7 @@ interface TestStdout {
* work:
*
* ```js
* import test from 'test/reporters';
* import test from 'node:test/reporters';
* ```
* @since v19.9.0
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/test/reporters.js)
@@ -1833,31 +2083,47 @@ declare module "node:test/reporters" {
| { type: "test:watch:drained"; data: undefined };
type TestEventGenerator = AsyncGenerator<TestEvent, void>;
interface ReporterConstructorWrapper<T extends new(...args: any[]) => Transform> {
new(...args: ConstructorParameters<T>): InstanceType<T>;
(...args: ConstructorParameters<T>): InstanceType<T>;
}
/**
* 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`.
* @since v20.0.0
*/
function dot(source: TestEventGenerator): AsyncGenerator<"\n" | "." | "X", void>;
/**
* The `tap` reporter outputs the test results in the [TAP](https://testanything.org/) format.
* @since v20.0.0
*/
function tap(source: TestEventGenerator): AsyncGenerator<string, void>;
/**
* The `spec` reporter outputs the test results in a human-readable format.
*/
class Spec extends Transform {
class SpecReporter extends Transform {
constructor();
}
/**
* The `spec` reporter outputs the test results in a human-readable format.
* @since v20.0.0
*/
const spec: ReporterConstructorWrapper<typeof SpecReporter>;
/**
* The `junit` reporter outputs test results in a jUnit XML format.
* @since v21.0.0
*/
function junit(source: TestEventGenerator): AsyncGenerator<string, void>;
/**
* The `lcov` reporter outputs test coverage when used with the [`--experimental-test-coverage`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--experimental-test-coverage) flag.
*/
class Lcov extends Transform {
constructor(opts?: TransformOptions);
class LcovReporter extends Transform {
constructor(opts?: Omit<TransformOptions, "writableObjectMode">);
}
export { dot, junit, Lcov as lcov, Spec as spec, tap, TestEvent };
/**
* The `lcov` reporter outputs test coverage when used with the
* [`--experimental-test-coverage`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--experimental-test-coverage) flag.
* @since v22.0.0
*/
// TODO: change the export to a wrapper function once node@0db38f0 is merged (breaking change)
// const lcov: ReporterConstructorWrapper<typeof LcovReporter>;
const lcov: LcovReporter;
export { dot, junit, lcov, spec, tap, TestEvent };
}

View File

@@ -1,7 +1,7 @@
/**
* The `timer` module exposes a global API for scheduling functions to
* be called at some future period of time. Because the timer functions are
* globals, there is no need to call `require('node:timers')` to use the API.
* globals, there is no need to import `node:timers` to use the API.
*
* The timer functions within Node.js implement a similar API as the timers API
* provided by Web Browsers but use a different internal implementation that is

View File

@@ -1,13 +1,13 @@
/**
* The `timers/promises` API provides an alternative set of timer functions
* that return `Promise` objects. The API is accessible via `require('node:timers/promises')`.
* that return `Promise` objects. The API is accessible via `import timersPromises from 'node:timers/promises'`.
*
* ```js
* import {
* setTimeout,
* setImmediate,
* setInterval,
* } from 'timers/promises';
* } from 'node:timers/promises';
* ```
* @since v15.0.0
*/
@@ -17,7 +17,7 @@ declare module "timers/promises" {
* ```js
* import {
* setTimeout,
* } from 'timers/promises';
* } from 'node:timers/promises';
*
* const res = await setTimeout(100, 'result');
*
@@ -32,7 +32,7 @@ declare module "timers/promises" {
* ```js
* import {
* setImmediate,
* } from 'timers/promises';
* } from 'node:timers/promises';
*
* const res = await setImmediate('result');
*
@@ -50,7 +50,7 @@ declare module "timers/promises" {
* ```js
* import {
* setInterval,
* } from 'timers/promises';
* } from 'node:timers/promises';
*
* const interval = 100;
* for await (const startTime of setInterval(interval, Date.now())) {
@@ -80,7 +80,7 @@ declare module "timers/promises" {
* @experimental
* @param [delay=1] The number of milliseconds to wait before fulfilling the promise.
*/
wait: (delay?: number, options?: Pick<TimerOptions, "signal">) => Promise<void>;
wait: (delay?: number, options?: TimerOptions) => Promise<void>;
/**
* An experimental API defined by the [Scheduling APIs](https://nodejs.org/docs/latest-v20.x/api/async_hooks.html#promise-execution-tracking) draft specification
* being developed as a standard Web Platform API.

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

@@ -4,7 +4,7 @@
* The module can be accessed using:
*
* ```js
* const tls = require('node:tls');
* import tls from 'node:tls';
* ```
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/tls.js)
*/
@@ -809,6 +809,12 @@ declare module "tls" {
* 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;
/**
* Treat intermediate (non-self-signed)
* certificates in the trust CA certificate list as trusted.
* @since v22.9.0, v20.18.0
*/
allowPartialTrustChain?: boolean | undefined;
/**
* Optionally override the trusted CA certificates. Default is to trust
* the well-known CAs curated by Mozilla. Mozilla's CAs are completely
@@ -843,6 +849,7 @@ declare module "tls" {
ciphers?: string | undefined;
/**
* Name of an OpenSSL engine which can provide the client certificate.
* @deprecated
*/
clientCertEngine?: string | undefined;
/**
@@ -885,12 +892,14 @@ declare module "tls" {
/**
* Name of an OpenSSL engine to get private key from. Should be used
* together with privateKeyIdentifier.
* @deprecated
*/
privateKeyEngine?: string | undefined;
/**
* Identifier of a private key managed by an OpenSSL engine. Should be
* used together with privateKeyEngine. Should not be set together with
* key, because both options define a private key in different ways.
* @deprecated
*/
privateKeyIdentifier?: string | undefined;
/**
@@ -1000,8 +1009,8 @@ declare module "tls" {
* The following illustrates a simple echo server:
*
* ```js
* const tls = require('node:tls');
* const fs = require('node:fs');
* import tls from 'node:tls';
* import fs from 'node:fs';
*
* const options = {
* key: fs.readFileSync('server-key.pem'),
@@ -1046,8 +1055,8 @@ declare module "tls" {
*
* ```js
* // Assumes an echo server that is listening on port 8000.
* const tls = require('node:tls');
* const fs = require('node:fs');
* import tls from 'node:tls';
* import fs from 'node:fs';
*
* const options = {
* // Necessary only if the server requires client certificate authentication.

View File

@@ -53,7 +53,7 @@
* Alternatively, trace events may be enabled using the `node:trace_events` module:
*
* ```js
* const trace_events = require('node:trace_events');
* import trace_events from 'node:trace_events';
* const tracing = trace_events.createTracing({ categories: ['node.perf'] });
* tracing.enable(); // Enable trace event capture for the 'node.perf' category
*
@@ -118,7 +118,7 @@ declare module "trace_events" {
* will be disabled.
*
* ```js
* const trace_events = require('node:trace_events');
* import trace_events from 'node:trace_events';
* const t1 = trace_events.createTracing({ categories: ['node', 'v8'] });
* const t2 = trace_events.createTracing({ categories: ['node.perf', 'node'] });
* t1.enable();
@@ -159,7 +159,7 @@ declare module "trace_events" {
* Creates and returns a `Tracing` object for the given set of `categories`.
*
* ```js
* const trace_events = require('node:trace_events');
* import trace_events from 'node:trace_events';
* const categories = ['node.perf', 'node.async_hooks'];
* const tracing = trace_events.createTracing({ categories });
* tracing.enable();
@@ -178,7 +178,7 @@ declare module "trace_events" {
* Given the file `test.js` below, the command `node --trace-event-categories node.perf test.js` will print `'node.async_hooks,node.perf'` to the console.
*
* ```js
* const trace_events = require('node:trace_events');
* import trace_events from 'node:trace_events';
* const t1 = trace_events.createTracing({ categories: ['node.async_hooks'] });
* const t2 = trace_events.createTracing({ categories: ['node.perf'] });
* const t3 = trace_events.createTracing({ categories: ['v8'] });

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

@@ -3,7 +3,7 @@
* directly. However, it can be accessed using:
*
* ```js
* const tty = require('node:tty');
* import tty from 'node:tty';
* ```
*
* When Node.js detects that it is being run with a text terminal ("TTY")

25
node_modules/@types/node/url.d.ts generated vendored
View File

@@ -93,7 +93,7 @@ declare module "url" {
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
*
* ```js
* const url = require('node:url');
* import url from 'node:url';
* url.format({
* protocol: 'https',
* hostname: 'example.com',
@@ -157,7 +157,7 @@ declare module "url" {
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
*
* ```js
* const url = require('node:url');
* import url from 'node:url';
* url.format({
* protocol: 'https',
* hostname: 'example.com',
@@ -222,7 +222,7 @@ declare module "url" {
* manner similar to that of a web browser resolving an anchor tag.
*
* ```js
* const url = require('node:url');
* import url from 'node:url';
* url.resolve('/one/two/three', 'four'); // '/one/two/four'
* url.resolve('http://example.com/', '/one'); // 'http://example.com/one'
* url.resolve('http://example.com/one', '/two'); // 'http://example.com/two'
@@ -400,10 +400,10 @@ declare module "url" {
* Creates a `'blob:nodedata:...'` URL string that represents the given `Blob` object and can be used to retrieve the `Blob` later.
*
* ```js
* const {
* import {
* Blob,
* resolveObjectURL,
* } = require('node:buffer');
* } from 'node:buffer';
*
* const blob = new Blob(['hello']);
* const id = URL.createObjectURL(blob);
@@ -757,6 +757,9 @@ declare module "url" {
*/
toJSON(): string;
}
interface URLSearchParamsIterator<T> extends NodeJS.Iterator<T, NodeJS.BuiltinIteratorReturn, unknown> {
[Symbol.iterator](): URLSearchParamsIterator<T>;
}
/**
* The `URLSearchParams` API provides read and write access to the query of a `URL`. The `URLSearchParams` class can also be used standalone with one of the
* four following constructors.
@@ -827,7 +830,7 @@ declare module "url" {
*
* Alias for `urlSearchParams[@@iterator]()`.
*/
entries(): IterableIterator<[string, string]>;
entries(): URLSearchParamsIterator<[string, string]>;
/**
* Iterates over each name-value pair in the query and invokes the given function.
*
@@ -881,7 +884,7 @@ declare module "url" {
* // foo
* ```
*/
keys(): IterableIterator<string>;
keys(): URLSearchParamsIterator<string>;
/**
* Sets the value in the `URLSearchParams` object associated with `name` to `value`. If there are any pre-existing name-value pairs whose names are `name`,
* set the first such pair's value to `value` and remove all others. If not,
@@ -931,8 +934,8 @@ declare module "url" {
/**
* Returns an ES6 `Iterator` over the values of each name-value pair.
*/
values(): IterableIterator<string>;
[Symbol.iterator](): IterableIterator<[string, string]>;
values(): URLSearchParamsIterator<string>;
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
}
import { URL as _URL, URLSearchParams as _URLSearchParams } from "url";
global {
@@ -943,7 +946,7 @@ declare module "url" {
URLSearchParams: typeof _URLSearchParams;
}
/**
* `URL` class is a global reference for `require('url').URL`
* `URL` class is a global reference for `import { URL } from 'url'`
* https://nodejs.org/api/url.html#the-whatwg-url-api
* @since v10.0.0
*/
@@ -953,7 +956,7 @@ declare module "url" {
} ? T
: typeof _URL;
/**
* `URLSearchParams` class is a global reference for `require('url').URLSearchParams`
* `URLSearchParams` class is a global reference for `import { URLSearchParams } from 'node:url'`
* https://nodejs.org/api/url.html#class-urlsearchparams
* @since v10.0.0
*/

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

@@ -4,7 +4,7 @@
* it:
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
* ```
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/util.js)
*/
@@ -108,6 +108,25 @@ declare module "util" {
export interface InspectOptionsStylized extends InspectOptions {
stylize(text: string, styleType: Style): string;
}
export interface StacktraceObject {
/**
* Returns the name of the function associated with this stack frame.
*/
functionName: string;
/**
* Returns the name of the resource that contains the script for the
* function for this StackFrame.
*/
scriptName: string;
/**
* Returns the number, 1-based, of the line for the associate function call.
*/
lineNumber: number;
/**
* Returns the 1-based column offset on the line for the associated function call.
*/
column: number;
}
/**
* The `util.format()` method returns a formatted string using the first argument
* as a `printf`-like format string which can contain zero or more format
@@ -166,6 +185,52 @@ declare module "util" {
* @since v10.0.0
*/
export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string;
/**
* Returns an array of stacktrace objects containing the stack of
* the caller function.
*
* ```js
* const util = require('node:util');
*
* function exampleFunction() {
* const callSites = util.getCallSite();
*
* console.log('Call Sites:');
* callSites.forEach((callSite, index) => {
* console.log(`CallSite ${index + 1}:`);
* console.log(`Function Name: ${callSite.functionName}`);
* console.log(`Script Name: ${callSite.scriptName}`);
* console.log(`Line Number: ${callSite.lineNumber}`);
* console.log(`Column Number: ${callSite.column}`);
* });
* // CallSite 1:
* // Function Name: exampleFunction
* // Script Name: /home/example.js
* // Line Number: 5
* // Column Number: 26
*
* // CallSite 2:
* // Function Name: anotherFunction
* // Script Name: /home/example.js
* // Line Number: 22
* // Column Number: 3
*
* // ...
* }
*
* // A function to simulate another stack layer
* function anotherFunction() {
* exampleFunction();
* }
*
* anotherFunction();
* ```
* @param frames Number of frames returned in the stacktrace.
* **Default:** `10`. Allowable range is between 1 and 200.
* @return An array of stacktrace objects
* @since v22.9.0
*/
export function getCallSite(frames?: number): StacktraceObject[];
/**
* Returns the string name for a numeric error code that comes from a Node.js API.
* The mapping between error codes and error names is platform-dependent.
@@ -200,7 +265,7 @@ declare module "util" {
* timestamp.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.log('Timestamped message.');
* ```
@@ -287,7 +352,7 @@ declare module "util" {
* Circular references point to their anchor by using a reference index:
*
* ```js
* const { inspect } = require('node:util');
* import { inspect } from 'node:util';
*
* const obj = {};
* obj.a = [obj];
@@ -305,7 +370,7 @@ declare module "util" {
* The following example inspects all properties of the `util` object:
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* console.log(util.inspect(util, { showHidden: true, depth: null }));
* ```
@@ -313,7 +378,7 @@ declare module "util" {
* The following example highlights the effect of the `compact` option:
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* const o = {
* a: [1, 2, [[
@@ -370,7 +435,7 @@ declare module "util" {
* with no remaining strong references may be garbage collected at any time.
*
* ```js
* const { inspect } = require('node:util');
* import { inspect } from 'node:util';
*
* const obj = { a: 1 };
* const obj2 = { b: 2 };
@@ -384,8 +449,8 @@ declare module "util" {
* impact the result of `util.inspect()`.
*
* ```js
* const { inspect } = require('node:util');
* const assert = require('node:assert');
* import { inspect } from 'node:util';
* import assert from 'node:assert';
*
* const o1 = {
* b: [2, 3, 1],
@@ -412,7 +477,7 @@ declare module "util" {
* numbers.
*
* ```js
* const { inspect } = require('node:util');
* import { inspect } from 'node:util';
*
* const thousand = 1_000;
* const million = 1_000_000;
@@ -459,7 +524,7 @@ declare module "util" {
* Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isArray([]);
* // Returns: true
@@ -476,7 +541,7 @@ declare module "util" {
* Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isRegExp(/some regexp/);
* // Returns: true
@@ -493,7 +558,7 @@ declare module "util" {
* Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isDate(new Date());
* // Returns: true
@@ -510,7 +575,7 @@ declare module "util" {
* Returns `true` if the given `object` is an `Error`. Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isError(new Error());
* // Returns: true
@@ -524,7 +589,7 @@ declare module "util" {
* possible to obtain an incorrect result when the `object` argument manipulates `@@toStringTag`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
* const obj = { name: 'Error', message: 'an error occurred' };
*
* util.isError(obj);
@@ -549,8 +614,8 @@ declare module "util" {
* through the `constructor.super_` property.
*
* ```js
* const util = require('node:util');
* const EventEmitter = require('node:events');
* import util from 'node:util';
* import EventEmitter from 'node:events';
*
* function MyStream() {
* EventEmitter.call(this);
@@ -576,7 +641,7 @@ declare module "util" {
* ES6 example using `class` and `extends`:
*
* ```js
* const EventEmitter = require('node:events');
* import EventEmitter from 'node:events';
*
* class MyStream extends EventEmitter {
* write(data) {
@@ -605,7 +670,7 @@ declare module "util" {
* environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
* const debuglog = util.debuglog('foo');
*
* debuglog('hello from foo [%d]', 123);
@@ -624,7 +689,7 @@ declare module "util" {
* The `section` supports wildcard also:
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
* const debuglog = util.debuglog('foo-bar');
*
* debuglog('hi there, it\'s foo-bar [%d]', 2333);
@@ -644,7 +709,7 @@ declare module "util" {
* unnecessary wrapping.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
* let debuglog = util.debuglog('internals', (debug) => {
* // Replace with a logging function that optimizes out
* // testing if the section is enabled
@@ -662,7 +727,7 @@ declare module "util" {
* Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isBoolean(1);
* // Returns: false
@@ -679,7 +744,7 @@ declare module "util" {
* Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isBuffer({ length: 0 });
* // Returns: false
@@ -696,7 +761,7 @@ declare module "util" {
* Returns `true` if the given `object` is a `Function`. Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* function Foo() {}
* const Bar = () => {};
@@ -716,7 +781,7 @@ declare module "util" {
* Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isNull(0);
* // Returns: false
@@ -734,7 +799,7 @@ declare module "util" {
* returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isNullOrUndefined(0);
* // Returns: false
@@ -751,7 +816,7 @@ declare module "util" {
* Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isNumber(false);
* // Returns: false
@@ -771,7 +836,7 @@ declare module "util" {
* Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isObject(5);
* // Returns: false
@@ -790,7 +855,7 @@ declare module "util" {
* Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isPrimitive(5);
* // Returns: true
@@ -819,7 +884,7 @@ declare module "util" {
* Returns `true` if the given `object` is a `string`. Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isString('');
* // Returns: true
@@ -838,7 +903,7 @@ declare module "util" {
* Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* util.isSymbol(5);
* // Returns: false
@@ -855,7 +920,7 @@ declare module "util" {
* Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* const foo = undefined;
* util.isUndefined(5);
@@ -874,7 +939,7 @@ declare module "util" {
* such a way that it is marked as deprecated.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* exports.obsoleteFunction = util.deprecate(() => {
* // Do something here.
@@ -890,7 +955,7 @@ declare module "util" {
* the warning will be emitted only once for that `code`.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001');
* const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001');
@@ -944,7 +1009,7 @@ declare module "util" {
* first argument will be the rejection reason (or `null` if the `Promise` resolved), and the second argument will be the resolved value.
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* async function fn() {
* return 'hello world';
@@ -1070,8 +1135,8 @@ declare module "util" {
* that returns promises.
*
* ```js
* const util = require('node:util');
* const fs = require('node:fs');
* import util from 'node:util';
* import fs from 'node:fs';
*
* const stat = util.promisify(fs.stat);
* stat('.').then((stats) => {
@@ -1084,8 +1149,8 @@ declare module "util" {
* Or, equivalently using `async function`s:
*
* ```js
* const util = require('node:util');
* const fs = require('node:fs');
* import util from 'node:util';
* import fs from 'node:fs';
*
* const stat = util.promisify(fs.stat);
*
@@ -1108,7 +1173,7 @@ declare module "util" {
* work as expected unless handled specially:
*
* ```js
* const util = require('node:util');
* import util from 'node:util';
*
* class Foo {
* constructor() {
@@ -1178,7 +1243,7 @@ declare module "util" {
* Given an example `.env` file:
*
* ```js
* const { parseEnv } = require('node:util');
* import { parseEnv } from 'node:util';
*
* parseEnv('HELLO=world\nHELLO=oh my\n');
* // Returns: { HELLO: 'oh my' }
@@ -1247,7 +1312,7 @@ declare module "util" {
* This function returns a formatted text considering the `format` passed.
*
* ```js
* const { styleText } = require('node:util');
* import { styleText } from 'node:util';
* const errorMessage = styleText('red', 'Error! Error!');
* console.log(errorMessage);
* ```
@@ -1383,7 +1448,7 @@ declare module "util" {
import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from "util";
global {
/**
* `TextDecoder` class is a global reference for `require('util').TextDecoder`
* `TextDecoder` class is a global reference for `import { TextDecoder } from 'node:util'`
* https://nodejs.org/api/globals.html#textdecoder
* @since v11.0.0
*/
@@ -1393,7 +1458,7 @@ declare module "util" {
} ? TextDecoder
: typeof _TextDecoder;
/**
* `TextEncoder` class is a global reference for `require('util').TextEncoder`
* `TextEncoder` class is a global reference for `import { TextEncoder } from 'node:util'`
* https://nodejs.org/api/globals.html#textencoder
* @since v11.0.0
*/
@@ -1480,6 +1545,12 @@ declare module "util" {
* Whether this command accepts positional arguments.
*/
allowPositionals?: boolean | undefined;
/**
* If `true`, allows explicitly setting boolean options to `false` by prefixing the option name with `--no-`.
* @default false
* @since v22.4.0
*/
allowNegative?: boolean | undefined;
/**
* Return the parsed tokens. This is useful for extending the built-in behavior,
* from adding additional checks through to reprocessing the tokens in different ways.
@@ -1511,15 +1582,23 @@ declare module "util" {
string | boolean
>;
type ApplyOptionalModifiers<O extends ParseArgsOptionsConfig, V extends Record<keyof O, unknown>> = (
& { -readonly [LongOption in keyof O]?: V[LongOption] }
& { [LongOption in keyof O as O[LongOption]["default"] extends {} ? LongOption : never]: V[LongOption] }
) extends infer P ? { [K in keyof P]: P[K] } : never; // resolve intersection to object
type ParsedValues<T extends ParseArgsConfig> =
& IfDefaultsTrue<T["strict"], unknown, { [longOption: string]: undefined | string | boolean }>
& (T["options"] extends ParseArgsOptionsConfig ? {
-readonly [LongOption in keyof T["options"]]: IfDefaultsFalse<
T["options"][LongOption]["multiple"],
undefined | Array<ExtractOptionValue<T, T["options"][LongOption]>>,
undefined | ExtractOptionValue<T, T["options"][LongOption]>
>;
}
& (T["options"] extends ParseArgsOptionsConfig ? ApplyOptionalModifiers<
T["options"],
{
[LongOption in keyof T["options"]]: IfDefaultsFalse<
T["options"][LongOption]["multiple"],
Array<ExtractOptionValue<T, T["options"][LongOption]>>,
ExtractOptionValue<T, T["options"][LongOption]>
>;
}
>
: {});
type ParsedPositionals<T extends ParseArgsConfig> = IfDefaultsTrue<
@@ -1711,7 +1790,7 @@ declare module "util" {
* 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(): NodeJS.Iterator<[name: string, value: string]>;
/**
* Returns the value of the first name-value pair whose name is `name`. If there
* are no such pairs, `null` is returned.
@@ -1737,7 +1816,7 @@ declare module "util" {
* // bar
* ```
*/
keys(): IterableIterator<string>;
keys(): NodeJS.Iterator<string>;
/**
* 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`,
* set the first such pair's value to `value`.
@@ -1756,11 +1835,11 @@ declare module "util" {
/**
* Returns an iterator over the values of each name-value pair.
*/
values(): IterableIterator<string>;
values(): NodeJS.Iterator<string>;
/**
* Returns an iterator over each of the name-value pairs in the parameters.
*/
[Symbol.iterator]: typeof MIMEParams.prototype.entries;
[Symbol.iterator](): NodeJS.Iterator<[name: string, value: string]>;
}
}
declare module "util/types" {
@@ -2078,7 +2157,7 @@ declare module "util/types" {
* which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false` for these errors:
*
* ```js
* const vm = require('node:vm');
* import vm from 'node:vm';
* const context = vm.createContext({});
* const myError = vm.runInContext('new Error()', context);
* console.log(util.types.isNativeError(myError)); // true

24
node_modules/@types/node/v8.d.ts generated vendored
View File

@@ -2,7 +2,7 @@
* The `node:v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using:
*
* ```js
* const v8 = require('node:v8');
* import v8 from 'node:v8';
* ```
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/v8.js)
*/
@@ -176,7 +176,7 @@ declare module "v8" {
*
* ```js
* // Print GC events to stdout for one minute.
* const v8 = require('node:v8');
* import v8 from 'node:v8';
* v8.setFlagsFromString('--trace_gc');
* setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
* ```
@@ -243,7 +243,7 @@ declare module "v8" {
*
* ```js
* // Print heap snapshot to the console
* const v8 = require('node:v8');
* import v8 from 'node:v8';
* const stream = v8.getHeapSnapshot();
* stream.pipe(process.stdout);
* ```
@@ -268,12 +268,12 @@ declare module "v8" {
* for a duration depending on the heap size.
*
* ```js
* const { writeHeapSnapshot } = require('node:v8');
* const {
* import { writeHeapSnapshot } from 'node:v8';
* import {
* Worker,
* isMainThread,
* parentPort,
* } = require('node:worker_threads');
* } from 'node:worker_threads';
*
* if (isMainThread) {
* const worker = new Worker(__filename);
@@ -550,7 +550,7 @@ declare module "v8" {
* Here's an example.
*
* ```js
* const { GCProfiler } = require('v8');
* import { GCProfiler } from 'node:v8';
* const profiler = new GCProfiler();
* profiler.start();
* setTimeout(() => {
@@ -736,12 +736,12 @@ declare module "v8" {
* ```js
* 'use strict';
*
* const fs = require('node:fs');
* const zlib = require('node:zlib');
* const path = require('node:path');
* const assert = require('node:assert');
* import fs from 'node:fs';
* import zlib from 'node:zlib';
* import path from 'node:path';
* import assert from 'node:assert';
*
* const v8 = require('node:v8');
* import v8 from 'node:v8';
*
* class BookShelf {
* storage = new Map();

122
node_modules/@types/node/vm.d.ts generated vendored
View File

@@ -17,7 +17,7 @@
* code are reflected in the context object.
*
* ```js
* const vm = require('node:vm');
* import vm from 'node:vm';
*
* const x = 1;
*
@@ -203,7 +203,7 @@ declare module "vm" {
* The globals are contained in the `context` object.
*
* ```js
* const vm = require('node:vm');
* import vm from 'node:vm';
*
* const context = {
* animal: 'cat',
@@ -230,9 +230,16 @@ declare module "vm" {
*/
runInContext(contextifiedObject: Context, options?: RunningScriptOptions): any;
/**
* First contextifies the given `contextObject`, runs the compiled code contained
* by the `vm.Script` object within the created context, and returns the result.
* Running code does not have access to local scope.
* This method is a shortcut to `script.runInContext(vm.createContext(options), options)`.
* It does several things at once:
*
* 1. Creates a new context.
* 2. If `contextObject` is an object, contextifies it with the new context.
* If `contextObject` is undefined, creates a new object and contextifies it.
* If `contextObject` is `vm.constants.DONT_CONTEXTIFY`, don't contextify anything.
* 3. Runs the compiled code contained by the `vm.Script` object within the created context. The code
* does not have access to the scope in which this method is called.
* 4. Returns the result.
*
* The following example compiles code that sets a global variable, then executes
* the code multiple times in different contexts. The globals are set on and
@@ -250,12 +257,22 @@ declare module "vm" {
*
* console.log(contexts);
* // Prints: [{ globalVar: 'set' }, { globalVar: 'set' }, { globalVar: 'set' }]
*
* // This would throw if the context is created from a contextified object.
* // vm.constants.DONT_CONTEXTIFY allows creating contexts with ordinary
* // global objects that can be frozen.
* const freezeScript = new vm.Script('Object.freeze(globalThis); globalThis;');
* const frozenContext = freezeScript.runInNewContext(vm.constants.DONT_CONTEXTIFY);
* ```
* @since v0.3.1
* @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
* @param contextObject Either `vm.constants.DONT_CONTEXTIFY` or an object that will be contextified.
* If `undefined`, an empty contextified object will be created for backwards compatibility.
* @return the result of the very last statement executed in the script.
*/
runInNewContext(contextObject?: Context, options?: RunningScriptInNewContextOptions): any;
runInNewContext(
contextObject?: Context | typeof constants.DONT_CONTEXTIFY,
options?: RunningScriptInNewContextOptions,
): any;
/**
* Runs the compiled code contained by the `vm.Script` within the context of the
* current `global` object. Running code does not have access to local scope, but _does_ have access to the current `global` object.
@@ -264,7 +281,7 @@ declare module "vm" {
* executes that code multiple times:
*
* ```js
* const vm = require('node:vm');
* import vm from 'node:vm';
*
* global.globalVar = 0;
*
@@ -347,13 +364,13 @@ declare module "vm" {
sourceMapURL?: string | undefined;
}
/**
* If given a `contextObject`, the `vm.createContext()` method will
* If the given `contextObject` is an object, the `vm.createContext()` method will
* [prepare that object](https://nodejs.org/docs/latest-v22.x/api/vm.html#what-does-it-mean-to-contextify-an-object)
* and return a reference to it so that it can be used in `{@link runInContext}` or
* [`script.runInContext()`](https://nodejs.org/docs/latest-v22.x/api/vm.html#scriptrunincontextcontextifiedobject-options). Inside such
* scripts, the `contextObject` will be the global object, retaining all of its
* existing properties but also having the built-in objects and functions any
* standard [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global
* and return a reference to it so that it can be used in calls to {@link runInContext} or
* [`script.runInContext()`](https://nodejs.org/docs/latest-v22.x/api/vm.html#scriptrunincontextcontextifiedobject-options).
* Inside such scripts, the global object will be wrapped by the `contextObject`, retaining all of its
* existing properties but also having the built-in objects and functions any standard
* [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global
* variables will remain unchanged.
*
* ```js
@@ -374,7 +391,12 @@ declare module "vm" {
* ```
*
* If `contextObject` is omitted (or passed explicitly as `undefined`), a new,
* empty `contextified` object will be returned.
* empty contextified object will be returned.
*
* When the global object in the newly created context is contextified, it has some quirks
* compared to ordinary global objects. For example, it cannot be frozen. To create a context
* without the contextifying quirks, pass `vm.constants.DONT_CONTEXTIFY` as the `contextObject`
* argument. See the documentation of `vm.constants.DONT_CONTEXTIFY` for details.
*
* The `vm.createContext()` method is primarily useful for creating a single
* context that can be used to run multiple scripts. For instance, if emulating a
@@ -385,11 +407,17 @@ declare module "vm" {
* The provided `name` and `origin` of the context are made visible through the
* Inspector API.
* @since v0.3.1
* @param contextObject Either `vm.constants.DONT_CONTEXTIFY` or an object that will be contextified.
* If `undefined`, an empty contextified object will be created for backwards compatibility.
* @return contextified object.
*/
function createContext(sandbox?: Context, options?: CreateContextOptions): Context;
function createContext(
contextObject?: Context | typeof constants.DONT_CONTEXTIFY,
options?: CreateContextOptions,
): Context;
/**
* Returns `true` if the given `object` object has been `contextified` using {@link createContext}.
* Returns `true` if the given `object` object has been contextified using {@link createContext},
* or if it's the global object of a context created using `vm.constants.DONT_CONTEXTIFY`.
* @since v0.11.7
*/
function isContext(sandbox: Context): boolean;
@@ -404,7 +432,7 @@ declare module "vm" {
* The following example compiles and executes different scripts using a single `contextified` object:
*
* ```js
* const vm = require('node:vm');
* import vm from 'node:vm';
*
* const contextObject = { globalVar: 1 };
* vm.createContext(contextObject);
@@ -422,13 +450,21 @@ declare module "vm" {
*/
function runInContext(code: string, contextifiedObject: Context, options?: RunningCodeOptions | string): any;
/**
* The `vm.runInNewContext()` first contextifies the given `contextObject` (or
* creates a new `contextObject` if passed as `undefined`), compiles the `code`,
* runs it within the created context, then returns the result. Running code
* does not have access to the local scope.
*
* This method is a shortcut to
* `(new vm.Script(code, options)).runInContext(vm.createContext(options), options)`.
* If `options` is a string, then it specifies the filename.
*
* It does several things at once:
*
* 1. Creates a new context.
* 2. If `contextObject` is an object, contextifies it with the new context.
* If `contextObject` is undefined, creates a new object and contextifies it.
* If `contextObject` is `vm.constants.DONT_CONTEXTIFY`, don't contextify anything.
* 3. Compiles the code as a`vm.Script`
* 4. Runs the compield code within the created context. The code does not have access to the scope in
* which this method is called.
* 5. Returns the result.
*
* The following example compiles and executes code that increments a global
* variable and sets a new one. These globals are contained in the `contextObject`.
*
@@ -443,15 +479,21 @@ declare module "vm" {
* vm.runInNewContext('count += 1; name = "kitty"', contextObject);
* console.log(contextObject);
* // Prints: { animal: 'cat', count: 3, name: 'kitty' }
*
* // This would throw if the context is created from a contextified object.
* // vm.constants.DONT_CONTEXTIFY allows creating contexts with ordinary global objects that
* // can be frozen.
* const frozenContext = vm.runInNewContext('Object.freeze(globalThis); globalThis;', vm.constants.DONT_CONTEXTIFY);
* ```
* @since v0.3.1
* @param code The JavaScript code to compile and run.
* @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
* @param contextObject Either `vm.constants.DONT_CONTEXTIFY` or an object that will be contextified.
* If `undefined`, an empty contextified object will be created for backwards compatibility.
* @return the result of the very last statement executed in the script.
*/
function runInNewContext(
code: string,
contextObject?: Context,
contextObject?: Context | typeof constants.DONT_CONTEXTIFY,
options?: RunningCodeInNewContextOptions | string,
): any;
/**
@@ -465,7 +507,7 @@ declare module "vm" {
* the JavaScript [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) function to run the same code:
*
* ```js
* const vm = require('node:vm');
* import vm from 'node:vm';
* let localVar = 'initial value';
*
* const vmResult = vm.runInThisContext('localVar = "vm";');
@@ -487,16 +529,16 @@ declare module "vm" {
* context. The code passed to this VM context will have its own isolated scope.
*
* In order to run a simple web server using the `node:http` module the code passed
* to the context must either call `require('node:http')` on its own, or have a
* to the context must either import `node:http` on its own, or have a
* reference to the `node:http` module passed to it. For instance:
*
* ```js
* 'use strict';
* const vm = require('node:vm');
* import vm from 'node:vm';
*
* const code = `
* ((require) => {
* const http = require('node:http');
* const http = require('node:http');
*
* http.createServer((request, response) => {
* response.writeHead(200, { 'Content-Type': 'text/plain' });
@@ -547,7 +589,7 @@ declare module "vm" {
* the memory occupied by each heap space in the current V8 instance.
*
* ```js
* const vm = require('node:vm');
* import vm from 'node:vm';
* // Measure the memory used by the main context.
* vm.measureMemory({ mode: 'summary' })
* // This is the same as vm.measureMemory()
@@ -853,7 +895,7 @@ declare module "vm" {
* module graphs.
*
* ```js
* const vm = require('node:vm');
* import vm from 'node:vm';
*
* const source = '{ "a": 1 }';
* const module = new vm.SyntheticModule(['default'], function() {
@@ -902,19 +944,31 @@ declare module "vm" {
}
/**
* Returns an object containing commonly used constants for VM operations.
* @since v20.12.0
* @since v21.7.0, v20.12.0
*/
namespace constants {
/**
* Stability: 1.1 - Active development
*
* A constant that can be used as the `importModuleDynamically` option to `vm.Script`
* and `vm.compileFunction()` so that Node.js uses the default ESM loader from the main
* context to load the requested module.
*
* For detailed information, see [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v22.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
* @since v21.7.0, v20.12.0
*/
const USE_MAIN_CONTEXT_DEFAULT_LOADER: number;
/**
* This constant, when used as the `contextObject` argument in vm APIs, instructs Node.js to create
* a context without wrapping its global object with another object in a Node.js-specific manner.
* As a result, the `globalThis` value inside the new context would behave more closely to an ordinary
* one.
*
* When `vm.constants.DONT_CONTEXTIFY` is used as the `contextObject` argument to {@link createContext},
* the returned object is a proxy-like object to the global object in the newly created context with
* fewer Node.js-specific quirks. It is reference equal to the `globalThis` value in the new context,
* can be modified from outside the context, and can be used to access built-ins in the new context directly.
* @since v22.8.0
*/
const DONT_CONTEXTIFY: number;
}
}
declare module "node:vm" {

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

@@ -9,7 +9,7 @@
*
* ```js
* import { readFile } from 'node:fs/promises';
* import { WASI } from 'wasi';
* import { WASI } from 'node:wasi';
* import { argv, env } from 'node:process';
*
* const wasi = new WASI({

View File

@@ -3,7 +3,7 @@
* JavaScript in parallel. To access it:
*
* ```js
* const worker = require('node:worker_threads');
* import worker from 'node:worker_threads';
* ```
*
* Workers (threads) are useful for performing CPU-intensive JavaScript operations.
@@ -14,9 +14,10 @@
* so by transferring `ArrayBuffer` instances or sharing `SharedArrayBuffer` instances.
*
* ```js
* const {
* import {
* Worker, isMainThread, parentPort, workerData,
* } = require('node:worker_threads');
* } from 'node:worker_threads';
* import { parse } from 'some-js-parsing-library';
*
* if (isMainThread) {
* module.exports = function parseJSAsync(script) {
@@ -33,7 +34,6 @@
* });
* };
* } else {
* const { parse } = require('some-js-parsing-library');
* const script = workerData;
* parentPort.postMessage(parse(script));
* }
@@ -72,7 +72,7 @@ declare module "worker_threads" {
* The `MessageChannel` has no methods of its own. `new MessageChannel()` yields an object with `port1` and `port2` properties, which refer to linked `MessagePort` instances.
*
* ```js
* const { MessageChannel } = require('node:worker_threads');
* import { MessageChannel } from 'node:worker_threads';
*
* const { port1, port2 } = new MessageChannel();
* port1.on('message', (message) => console.log('received', message));
@@ -121,7 +121,7 @@ declare module "worker_threads" {
* * `value` may not contain native (C++-backed) objects other than:
*
* ```js
* const { MessageChannel } = require('node:worker_threads');
* import { MessageChannel } from 'node:worker_threads';
* const { port1, port2 } = new MessageChannel();
*
* port1.on('message', (message) => console.log(message));
@@ -143,7 +143,7 @@ declare module "worker_threads" {
* `value` may still contain `ArrayBuffer` instances that are not in `transferList`; in that case, the underlying memory is copied rather than moved.
*
* ```js
* const { MessageChannel } = require('node:worker_threads');
* import { MessageChannel } from 'node:worker_threads';
* const { port1, port2 } = new MessageChannel();
*
* port1.on('message', (message) => console.log(message));
@@ -267,7 +267,7 @@ declare module "worker_threads" {
trackUnmanagedFds?: boolean | undefined;
/**
* An optional `name` to be appended to the worker title
* for debuggin/identification purposes, making the final title as
* for debugging/identification purposes, making the final title as
* `[worker ${id}] ${name}`.
*/
name?: string | undefined;
@@ -298,8 +298,8 @@ declare module "worker_threads" {
* Notable differences inside a Worker environment are:
*
* * The `process.stdin`, `process.stdout`, and `process.stderr` streams may be redirected by the parent thread.
* * The `require('node:worker_threads').isMainThread` property is set to `false`.
* * The `require('node:worker_threads').parentPort` message port is available.
* * The `import { isMainThread } from 'node:worker_threads'` variable is set to `false`.
* * The `import { parentPort } from 'node:worker_threads'` message port is available.
* * `process.exit()` does not stop the whole program, just the single thread,
* and `process.abort()` is not available.
* * `process.chdir()` and `process` methods that set group or user ids
@@ -334,10 +334,10 @@ declare module "worker_threads" {
* the thread barrier.
*
* ```js
* const assert = require('node:assert');
* const {
* import assert from 'node:assert';
* import {
* Worker, MessageChannel, MessagePort, isMainThread, parentPort,
* } = require('node:worker_threads');
* } from 'node:worker_threads';
* if (isMainThread) {
* const worker = new Worker(__filename);
* const subChannel = new MessageChannel();
@@ -377,7 +377,7 @@ declare module "worker_threads" {
readonly stderr: Readable;
/**
* An integer identifier for the referenced thread. Inside the worker thread,
* it is available as `require('node:worker_threads').threadId`.
* it is available as `import { threadId } from 'node:worker_threads'`.
* This value is unique for each `Worker` instance inside a single process.
* @since v10.5.0
*/
@@ -409,6 +409,24 @@ declare module "worker_threads" {
* @since v10.5.0
*/
postMessage(value: any, transferList?: readonly TransferListItem[]): void;
/**
* Sends a value to another worker, identified by its thread ID.
* @param threadId The target thread ID. If the thread ID is invalid, a `ERR_WORKER_MESSAGING_FAILED` error will be thrown.
* If the target thread ID is the current thread ID, a `ERR_WORKER_MESSAGING_SAME_THREAD` error will be thrown.
* @param value The value to send.
* @param transferList If one or more `MessagePort`-like objects are passed in value, a `transferList` is required for those items
* or `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` is thrown. See `port.postMessage()` for more information.
* @param timeout Time to wait for the message to be delivered in milliseconds. By default it's `undefined`, which means wait forever.
* If the operation times out, a `ERR_WORKER_MESSAGING_TIMEOUT` error is thrown.
* @since v22.5.0
*/
postMessageToThread(threadId: number, value: any, timeout?: number): Promise<void>;
postMessageToThread(
threadId: number,
value: any,
transferList: readonly TransferListItem[],
timeout?: number,
): Promise<void>;
/**
* Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker does _not_ let the program exit if it's the only active handle left (the default
* behavior). If the worker is `ref()`ed, calling `ref()` again has
@@ -495,11 +513,11 @@ declare module "worker_threads" {
* ```js
* 'use strict';
*
* const {
* import {
* isMainThread,
* BroadcastChannel,
* Worker,
* } = require('node:worker_threads');
* } from 'node:worker_threads';
*
* const bc = new BroadcastChannel('hello');
*
@@ -553,7 +571,7 @@ declare module "worker_threads" {
* This operation cannot be undone.
*
* ```js
* const { MessageChannel, markAsUntransferable } = require('node:worker_threads');
* import { MessageChannel, markAsUntransferable } from 'node:worker_threads';
*
* const pooledBuffer = new ArrayBuffer(8);
* const typedArray1 = new Uint8Array(pooledBuffer);
@@ -598,7 +616,7 @@ declare module "worker_threads" {
* that contains the message payload, corresponding to the oldest message in the `MessagePort`'s queue.
*
* ```js
* const { MessageChannel, receiveMessageOnPort } = require('node:worker_threads');
* import { MessageChannel, receiveMessageOnPort } from 'node:worker_threads';
* const { port1, port2 } = new MessageChannel();
* port1.postMessage({ hello: 'world' });
*
@@ -624,12 +642,12 @@ declare module "worker_threads" {
* automatically.
*
* ```js
* const {
* import {
* Worker,
* isMainThread,
* setEnvironmentData,
* getEnvironmentData,
* } = require('node:worker_threads');
* } from 'node:worker_threads';
*
* if (isMainThread) {
* setEnvironmentData('Hello', 'World!');
@@ -658,7 +676,7 @@ declare module "worker_threads" {
} from "worker_threads";
global {
/**
* `BroadcastChannel` class is a global reference for `require('worker_threads').BroadcastChannel`
* `BroadcastChannel` class is a global reference for `import { BroadcastChannel } from 'worker_threads'`
* https://nodejs.org/api/globals.html#broadcastchannel
* @since v18.0.0
*/
@@ -668,7 +686,7 @@ declare module "worker_threads" {
} ? T
: typeof _BroadcastChannel;
/**
* `MessageChannel` class is a global reference for `require('worker_threads').MessageChannel`
* `MessageChannel` class is a global reference for `import { MessageChannel } from 'worker_threads'`
* https://nodejs.org/api/globals.html#messagechannel
* @since v15.0.0
*/
@@ -678,7 +696,7 @@ declare module "worker_threads" {
} ? T
: typeof _MessageChannel;
/**
* `MessagePort` class is a global reference for `require('worker_threads').MessagePort`
* `MessagePort` class is a global reference for `import { MessagePort } from 'worker_threads'`
* https://nodejs.org/api/globals.html#messageport
* @since v15.0.0
*/

16
node_modules/@types/node/zlib.d.ts generated vendored
View File

@@ -5,7 +5,7 @@
* To access it:
*
* ```js
* const zlib = require('node:zlib');
* import zlib from 'node:zlib';
* ```
*
* Compression and decompression are built around the Node.js
@@ -16,12 +16,12 @@
* stream:
*
* ```js
* const { createGzip } = require('node:zlib');
* const { pipeline } = require('node:stream');
* const {
* import { createGzip } from 'node:zlib';
* import { pipeline } from 'node:stream';
* import {
* createReadStream,
* createWriteStream,
* } = require('node:fs');
* } from 'node:fs';
*
* const gzip = createGzip();
* const source = createReadStream('input.txt');
@@ -36,7 +36,7 @@
*
* // Or, Promisified
*
* const { promisify } = require('node:util');
* import { promisify } from 'node:util';
* const pipe = promisify(pipeline);
*
* async function do_gzip(input, output) {
@@ -56,7 +56,7 @@
* It is also possible to compress or decompress data in a single step:
*
* ```js
* const { deflate, unzip } = require('node:zlib');
* import { deflate, unzip } from 'node:zlib';
*
* const input = '.................................';
* deflate(input, (err, buffer) => {
@@ -78,7 +78,7 @@
*
* // Or, Promisified
*
* const { promisify } = require('node:util');
* import { promisify } from 'node:util';
* const do_unzip = promisify(unzip);
*
* do_unzip(buffer)