@types/node 26.3.0 → 26.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node/README.md +1 -1
- node/buffer.buffer.d.ts +5 -0
- node/crypto.d.ts +0 -2
- node/dgram.d.ts +119 -4
- node/ffi.d.ts +1 -1
- node/fs/promises.d.ts +61 -65
- node/fs.d.ts +86 -76
- node/http.d.ts +1 -1
- node/http2.d.ts +2 -2
- node/index.d.ts +1 -0
- node/inspector.d.ts +2 -1
- node/net.d.ts +108 -16
- node/package.json +2 -2
- node/quic.d.ts +37 -11
- node/stream/iter.d.ts +4 -4
- node/tls.d.ts +24 -0
- node/ts5.6/buffer.buffer.d.ts +5 -0
- node/ts5.6/index.d.ts +1 -0
- node/ts5.7/index.d.ts +1 -0
- node/tty.d.ts +4 -3
- node/vfs.d.ts +210 -0
- node/vm.d.ts +1 -1
node/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Tue, 01 Sep 2026 20:06:05 GMT
|
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
|
13
13
|
|
|
14
14
|
# Credits
|
node/buffer.buffer.d.ts
CHANGED
|
@@ -463,4 +463,9 @@ declare module "node:buffer" {
|
|
|
463
463
|
*/
|
|
464
464
|
type AllowSharedBuffer = Buffer<ArrayBufferLike>;
|
|
465
465
|
}
|
|
466
|
+
/**
|
|
467
|
+
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
|
|
468
|
+
* TypeScript versions earlier than 5.7.
|
|
469
|
+
*/
|
|
470
|
+
type BufferView<T extends NodeJS.ArrayBufferView> = T extends NodeJS.ArrayBufferView<infer B> ? Buffer<B> : never;
|
|
466
471
|
}
|
node/crypto.d.ts
CHANGED
|
@@ -3475,7 +3475,6 @@ declare module "node:crypto" {
|
|
|
3475
3475
|
* ```
|
|
3476
3476
|
* @since v24.7.0
|
|
3477
3477
|
* @param algorithm Variant of Argon2, one of `"argon2d"`, `"argon2i"` or `"argon2id"`.
|
|
3478
|
-
* @experimental
|
|
3479
3478
|
*/
|
|
3480
3479
|
function argon2(
|
|
3481
3480
|
algorithm: Argon2Algorithm,
|
|
@@ -3515,7 +3514,6 @@ declare module "node:crypto" {
|
|
|
3515
3514
|
* console.log(derivedKey.toString('hex')); // 'af91dad...9520f15'
|
|
3516
3515
|
* ```
|
|
3517
3516
|
* @since v24.7.0
|
|
3518
|
-
* @experimental
|
|
3519
3517
|
*/
|
|
3520
3518
|
function argon2Sync(algorithm: Argon2Algorithm, parameters: Argon2Parameters): NonSharedBuffer;
|
|
3521
3519
|
/**
|
node/dgram.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ declare module "node:dgram" {
|
|
|
15
15
|
exclusive?: boolean | undefined;
|
|
16
16
|
fd?: number | undefined;
|
|
17
17
|
}
|
|
18
|
+
interface BindSyncOptions {
|
|
19
|
+
port?: number | undefined;
|
|
20
|
+
address?: string | undefined;
|
|
21
|
+
}
|
|
18
22
|
type SocketType = "udp4" | "udp6";
|
|
19
23
|
interface SocketOptions extends Abortable {
|
|
20
24
|
type: SocketType;
|
|
@@ -117,10 +121,12 @@ declare module "node:dgram" {
|
|
|
117
121
|
* messages on a named `port` and optional `address`. If `port` is not
|
|
118
122
|
* specified or is `0`, the operating system will attempt to bind to a
|
|
119
123
|
* random port. If `address` is not specified, the operating system will
|
|
120
|
-
* attempt to listen on all addresses. Once binding is complete, a
|
|
124
|
+
* attempt to listen on all addresses. Once binding is complete, a
|
|
125
|
+
* `'listening'` event is emitted and the optional `callback` function is
|
|
121
126
|
* called.
|
|
122
127
|
*
|
|
123
|
-
* Specifying both a `'listening'` event listener and passing a
|
|
128
|
+
* Specifying both a `'listening'` event listener and passing a
|
|
129
|
+
* `callback` to the `socket.bind()` method is not harmful but not very
|
|
124
130
|
* useful.
|
|
125
131
|
*
|
|
126
132
|
* A bound datagram socket keeps the Node.js process running to receive
|
|
@@ -157,9 +163,82 @@ declare module "node:dgram" {
|
|
|
157
163
|
* @param callback with no parameters. Called when binding is complete.
|
|
158
164
|
*/
|
|
159
165
|
bind(port?: number, address?: string, callback?: () => void): this;
|
|
160
|
-
bind(port
|
|
161
|
-
bind(callback
|
|
166
|
+
bind(port: number, callback: () => void): this;
|
|
167
|
+
bind(callback: () => void): this;
|
|
168
|
+
/**
|
|
169
|
+
* For UDP sockets, causes the `dgram.Socket` to listen for datagram
|
|
170
|
+
* messages on a named `port` and optional `address` that are passed as
|
|
171
|
+
* properties of an `options` object passed as the first argument. If
|
|
172
|
+
* `port` is not specified or is `0`, the operating system will attempt
|
|
173
|
+
* to bind to a random port. If `address` is not specified, the operating
|
|
174
|
+
* system will attempt to listen on all addresses. Once binding is
|
|
175
|
+
* complete, a `'listening'` event is emitted and the optional `callback`
|
|
176
|
+
* function is called.
|
|
177
|
+
*
|
|
178
|
+
* The `options` object may contain a `fd` property. When a `fd` greater
|
|
179
|
+
* than `0` is set, it will wrap around an existing socket with the given
|
|
180
|
+
* file descriptor. In this case, the properties of `port` and `address`
|
|
181
|
+
* will be ignored.
|
|
182
|
+
*
|
|
183
|
+
* Specifying both a `'listening'` event listener and passing a
|
|
184
|
+
* `callback` to the `socket.bind()` method is not harmful but not very
|
|
185
|
+
* useful.
|
|
186
|
+
*
|
|
187
|
+
* The `options` object may contain an additional `exclusive` property that is
|
|
188
|
+
* used when using `dgram.Socket` objects with the [`cluster`](https://nodejs.org/docs/latest-v26.x/api/cluster.html) module. When
|
|
189
|
+
* `exclusive` is set to `false` (the default), cluster workers will use the same
|
|
190
|
+
* underlying socket handle allowing connection handling duties to be shared.
|
|
191
|
+
* When `exclusive` is `true`, however, the handle is not shared and attempted
|
|
192
|
+
* port sharing results in an error. Creating a `dgram.Socket` with the `reusePort`
|
|
193
|
+
* option set to `true` causes `exclusive` to always be `true` when `socket.bind()`
|
|
194
|
+
* is called.
|
|
195
|
+
*
|
|
196
|
+
* A bound datagram socket keeps the Node.js process running to receive
|
|
197
|
+
* datagram messages.
|
|
198
|
+
*
|
|
199
|
+
* If binding fails, an `'error'` event is generated. In rare case (e.g.
|
|
200
|
+
* attempting to bind with a closed socket), an `Error` may be thrown.
|
|
201
|
+
*
|
|
202
|
+
* An example socket listening on an exclusive port is shown below.
|
|
203
|
+
*
|
|
204
|
+
* ```js
|
|
205
|
+
* socket.bind({
|
|
206
|
+
* address: 'localhost',
|
|
207
|
+
* port: 8000,
|
|
208
|
+
* exclusive: true,
|
|
209
|
+
* });
|
|
210
|
+
* ```
|
|
211
|
+
* @since v0.11.14
|
|
212
|
+
* @param options Required. Supports the following properties:
|
|
213
|
+
*/
|
|
162
214
|
bind(options: BindOptions, callback?: () => void): this;
|
|
215
|
+
/**
|
|
216
|
+
* The synchronous counterpart of `socket.bind()`. `bind(2)` is a local,
|
|
217
|
+
* non-blocking system call, so the bind is performed inline and the resolved
|
|
218
|
+
* address is returned immediately, including the operating-system-assigned
|
|
219
|
+
* ephemeral port when `port` is `0`:
|
|
220
|
+
*
|
|
221
|
+
* ```js
|
|
222
|
+
* const dgram = require('node:dgram');
|
|
223
|
+
*
|
|
224
|
+
* const socket = dgram.createSocket('udp4');
|
|
225
|
+
* const address = socket.bindSync({ address: '0.0.0.0', port: 0 });
|
|
226
|
+
* console.log(address); // e.g. { address: '0.0.0.0', family: 'IPv4', port: 53124 }
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
* A bind failure such as `EADDRINUSE` is thrown synchronously rather than emitted
|
|
230
|
+
* as an `'error'` event. After `bindSync()` returns, `socket.address()` is
|
|
231
|
+
* valid synchronously and the `'listening'` event is emitted on the next tick.
|
|
232
|
+
*
|
|
233
|
+
* `address` must be a numeric IP literal; `bindSync()` never performs DNS
|
|
234
|
+
* resolution (asynchronous name resolution being the only genuinely blocking part
|
|
235
|
+
* of binding). Incoming datagrams continue to be delivered asynchronously via the
|
|
236
|
+
* `'message'` event. `bindSync()` always binds the socket's own handle and
|
|
237
|
+
* does not participate in [`cluster`](https://nodejs.org/docs/latest-v26.x/api/cluster.html) handle sharing.
|
|
238
|
+
* @since v26.4.0
|
|
239
|
+
* @returns The bound address as returned by `socket.address()`.
|
|
240
|
+
*/
|
|
241
|
+
bindSync(options?: BindSyncOptions): AddressInfo;
|
|
163
242
|
/**
|
|
164
243
|
* Close the underlying socket and stop listening for data on it. If a callback is
|
|
165
244
|
* provided, it is added as a listener for the `'close'` event.
|
|
@@ -182,6 +261,42 @@ declare module "node:dgram" {
|
|
|
182
261
|
*/
|
|
183
262
|
connect(port: number, address?: string, callback?: () => void): void;
|
|
184
263
|
connect(port: number, callback: () => void): void;
|
|
264
|
+
/**
|
|
265
|
+
* The synchronous counterpart of `socket.connect()`. For a UDP socket
|
|
266
|
+
* `connect(2)` only records the default peer address and is a local, non-blocking
|
|
267
|
+
* system call, so the association is performed inline. Any error raised by the
|
|
268
|
+
* call itself (for example `EAFNOSUPPORT` for a mismatched address family) is
|
|
269
|
+
* thrown synchronously rather than reported via the `'error'` event. Because
|
|
270
|
+
* `connect(2)` does not probe reachability, errors such as `ECONNREFUSED` are
|
|
271
|
+
* still surfaced asynchronously on a later send or receive, exactly as for
|
|
272
|
+
* `socket.connect()`:
|
|
273
|
+
*
|
|
274
|
+
* ```js
|
|
275
|
+
* const dgram = require('node:dgram');
|
|
276
|
+
*
|
|
277
|
+
* const socket = dgram.createSocket('udp4');
|
|
278
|
+
* socket.connectSync(41234, '127.0.0.1');
|
|
279
|
+
* console.log(socket.remoteAddress()); // { address: '127.0.0.1', family: 'IPv4', port: 41234 }
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* If the socket is still unbound it is bound synchronously first. After
|
|
283
|
+
* `connectSync()` returns, `socket.remoteAddress()` is valid synchronously
|
|
284
|
+
* and the `'connect'` event is emitted on the next tick. Trying to call
|
|
285
|
+
* `connectSync()` on an already connected socket throws an
|
|
286
|
+
* `ERR_SOCKET_DGRAM_IS_CONNECTED` exception, and calling it while an
|
|
287
|
+
* asynchronous [`socket.bind()`][] is still in progress throws an
|
|
288
|
+
* `ERR_SOCKET_ALREADY_BOUND` exception.
|
|
289
|
+
*
|
|
290
|
+
* `address` must be a numeric IP literal; `connectSync()` never performs DNS
|
|
291
|
+
* resolution (asynchronous name resolution being the only genuinely blocking part
|
|
292
|
+
* of connecting).
|
|
293
|
+
* @since v26.4.0
|
|
294
|
+
* @param address A numeric IP address to connect to. Unlike
|
|
295
|
+
* `socket.connect()`, no DNS resolution is performed, so a host name is not
|
|
296
|
+
* accepted. If omitted, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for
|
|
297
|
+
* `udp6` sockets) is used.
|
|
298
|
+
*/
|
|
299
|
+
connectSync(port: number, address?: string): void;
|
|
185
300
|
/**
|
|
186
301
|
* A synchronous function that disassociates a connected `dgram.Socket` from
|
|
187
302
|
* its remote address. Trying to call `disconnect()` on an unbound or already
|
node/ffi.d.ts
CHANGED
node/fs/promises.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare module "node:fs/promises" {
|
|
2
|
-
import { NonSharedBuffer } from "node:buffer";
|
|
2
|
+
import { BufferView, NonSharedBuffer } from "node:buffer";
|
|
3
3
|
import { Abortable } from "node:events";
|
|
4
4
|
import { Interface as ReadlineInterface } from "node:readline";
|
|
5
5
|
import {
|
|
@@ -20,6 +20,10 @@ declare module "node:fs/promises" {
|
|
|
20
20
|
OpenDirOptions,
|
|
21
21
|
OpenMode,
|
|
22
22
|
PathLike,
|
|
23
|
+
ReadFileOptions,
|
|
24
|
+
ReadFileOptionsWithBuffer,
|
|
25
|
+
ReadFileOptionsWithBufferEncoding,
|
|
26
|
+
ReadFileOptionsWithStringEncoding,
|
|
23
27
|
ReadOptions,
|
|
24
28
|
ReadOptionsWithBuffer,
|
|
25
29
|
ReadPosition,
|
|
@@ -36,7 +40,6 @@ declare module "node:fs/promises" {
|
|
|
36
40
|
WriteStream,
|
|
37
41
|
WriteVResult,
|
|
38
42
|
} from "node:fs";
|
|
39
|
-
import { Stream } from "node:stream";
|
|
40
43
|
import { ByteReadableStream, Transform, Writer } from "node:stream/iter";
|
|
41
44
|
import { ReadableStream } from "node:stream/web";
|
|
42
45
|
interface FileChangeInfo<T extends string | Buffer> {
|
|
@@ -357,39 +360,61 @@ declare module "node:fs/promises" {
|
|
|
357
360
|
*
|
|
358
361
|
* If `options` is a string, then it specifies the `encoding`.
|
|
359
362
|
*
|
|
363
|
+
* If `buffer` is provided and no encoding is specified, the returned {Buffer} is
|
|
364
|
+
* a view over the supplied buffer containing only the bytes read. If the
|
|
365
|
+
* supplied buffer is too small to contain the entire file, the operation will
|
|
366
|
+
* fail.
|
|
367
|
+
*
|
|
360
368
|
* The `FileHandle` has to support reading.
|
|
361
369
|
*
|
|
362
|
-
* If one or more `filehandle.read()` calls are made on a file handle and then a
|
|
370
|
+
* If one or more `filehandle.read()` calls are made on a file handle and then a
|
|
371
|
+
* `filehandle.readFile()` call is made, the data will be read from the current
|
|
363
372
|
* position till the end of the file. It doesn't always read from the beginning
|
|
364
373
|
* of the file.
|
|
374
|
+
*
|
|
375
|
+
* An example using the `buffer` option with a pre-allocated buffer:
|
|
376
|
+
*
|
|
377
|
+
* ```js
|
|
378
|
+
* import { Buffer } from 'node:buffer';
|
|
379
|
+
* import { open } from 'node:fs/promises';
|
|
380
|
+
*
|
|
381
|
+
* const file = await open('./some/file/to/read');
|
|
382
|
+
* try {
|
|
383
|
+
* const buf = Buffer.alloc(16384);
|
|
384
|
+
* const contents = await file.readFile({ buffer: buf });
|
|
385
|
+
* console.log(contents); // A view over `buf` containing only the bytes read
|
|
386
|
+
* } finally {
|
|
387
|
+
* await file.close();
|
|
388
|
+
* }
|
|
389
|
+
* ```
|
|
390
|
+
*
|
|
391
|
+
* An example using the `buffer` option with a function returning a buffer:
|
|
392
|
+
*
|
|
393
|
+
* ```js
|
|
394
|
+
* import { Buffer } from 'node:buffer';
|
|
395
|
+
* import { open } from 'node:fs/promises';
|
|
396
|
+
*
|
|
397
|
+
* const file = await open('./some/file/to/read');
|
|
398
|
+
* try {
|
|
399
|
+
* const contents = await file.readFile({
|
|
400
|
+
* buffer: (size) => Buffer.alloc(size),
|
|
401
|
+
* });
|
|
402
|
+
* console.log(contents);
|
|
403
|
+
* } finally {
|
|
404
|
+
* await file.close();
|
|
405
|
+
* }
|
|
406
|
+
* ```
|
|
365
407
|
* @since v10.0.0
|
|
366
|
-
* @
|
|
367
|
-
*
|
|
368
|
-
|
|
369
|
-
readFile(
|
|
370
|
-
options?:
|
|
371
|
-
| ({ encoding?: null | undefined } & Abortable)
|
|
372
|
-
| null,
|
|
373
|
-
): Promise<NonSharedBuffer>;
|
|
374
|
-
/**
|
|
375
|
-
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
|
376
|
-
* The `FileHandle` must have been opened for reading.
|
|
408
|
+
* @returns Fulfills upon a successful read with the contents of the
|
|
409
|
+
* file. If no encoding is specified (using `options.encoding`), the data is
|
|
410
|
+
* returned as a `Buffer` object. Otherwise, the data will be a string.
|
|
377
411
|
*/
|
|
378
|
-
readFile(
|
|
379
|
-
options:
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
): Promise<string>;
|
|
383
|
-
|
|
384
|
-
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
|
385
|
-
* The `FileHandle` must have been opened for reading.
|
|
386
|
-
*/
|
|
387
|
-
readFile(
|
|
388
|
-
options?:
|
|
389
|
-
| (ObjectEncodingOptions & Abortable)
|
|
390
|
-
| BufferEncoding
|
|
391
|
-
| null,
|
|
392
|
-
): Promise<string | NonSharedBuffer>;
|
|
412
|
+
readFile<T extends NodeJS.ArrayBufferView>(
|
|
413
|
+
options: Omit<ReadFileOptionsWithBuffer<T>, "flag">,
|
|
414
|
+
): Promise<BufferView<T>>;
|
|
415
|
+
readFile(options?: Omit<ReadFileOptionsWithBufferEncoding, "flag"> | null): Promise<NonSharedBuffer>;
|
|
416
|
+
readFile(options: Omit<ReadFileOptionsWithStringEncoding, "flag"> | BufferEncoding): Promise<string>;
|
|
417
|
+
readFile(options: Omit<ReadFileOptions, "flag"> | BufferEncoding | null): Promise<string | NonSharedBuffer>;
|
|
393
418
|
/**
|
|
394
419
|
* Convenience method to create a `readline` interface and stream over the file.
|
|
395
420
|
* See `filehandle.createReadStream()` for the options.
|
|
@@ -1310,50 +1335,21 @@ declare module "node:fs/promises" {
|
|
|
1310
1335
|
* @param path filename or `FileHandle`
|
|
1311
1336
|
* @return Fulfills with the contents of the file.
|
|
1312
1337
|
*/
|
|
1338
|
+
function readFile<T extends NodeJS.ArrayBufferView>(
|
|
1339
|
+
path: PathLike | FileHandle,
|
|
1340
|
+
options: ReadFileOptionsWithBuffer<T>,
|
|
1341
|
+
): Promise<BufferView<T>>;
|
|
1313
1342
|
function readFile(
|
|
1314
1343
|
path: PathLike | FileHandle,
|
|
1315
|
-
options?:
|
|
1316
|
-
| ({
|
|
1317
|
-
encoding?: null | undefined;
|
|
1318
|
-
flag?: OpenMode | undefined;
|
|
1319
|
-
} & Abortable)
|
|
1320
|
-
| null,
|
|
1344
|
+
options?: ReadFileOptionsWithBufferEncoding | null,
|
|
1321
1345
|
): Promise<NonSharedBuffer>;
|
|
1322
|
-
/**
|
|
1323
|
-
* Asynchronously reads the entire contents of a file.
|
|
1324
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1325
|
-
* If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
|
|
1326
|
-
* @param options An object that may contain an optional flag.
|
|
1327
|
-
* If a flag is not provided, it defaults to `'r'`.
|
|
1328
|
-
*/
|
|
1329
1346
|
function readFile(
|
|
1330
1347
|
path: PathLike | FileHandle,
|
|
1331
|
-
options:
|
|
1332
|
-
| ({
|
|
1333
|
-
encoding: BufferEncoding;
|
|
1334
|
-
flag?: OpenMode | undefined;
|
|
1335
|
-
} & Abortable)
|
|
1336
|
-
| BufferEncoding,
|
|
1348
|
+
options: ReadFileOptionsWithStringEncoding | BufferEncoding,
|
|
1337
1349
|
): Promise<string>;
|
|
1338
|
-
/**
|
|
1339
|
-
* Asynchronously reads the entire contents of a file.
|
|
1340
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1341
|
-
* If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
|
|
1342
|
-
* @param options An object that may contain an optional flag.
|
|
1343
|
-
* If a flag is not provided, it defaults to `'r'`.
|
|
1344
|
-
*/
|
|
1345
1350
|
function readFile(
|
|
1346
1351
|
path: PathLike | FileHandle,
|
|
1347
|
-
options
|
|
1348
|
-
| (
|
|
1349
|
-
& ObjectEncodingOptions
|
|
1350
|
-
& Abortable
|
|
1351
|
-
& {
|
|
1352
|
-
flag?: OpenMode | undefined;
|
|
1353
|
-
}
|
|
1354
|
-
)
|
|
1355
|
-
| BufferEncoding
|
|
1356
|
-
| null,
|
|
1352
|
+
options: ReadFileOptions | BufferEncoding | null,
|
|
1357
1353
|
): Promise<string | NonSharedBuffer>;
|
|
1358
1354
|
/**
|
|
1359
1355
|
* Asynchronously open a directory for iterative scanning. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for more detail.
|
node/fs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare module "node:fs" {
|
|
2
|
-
import { NonSharedBuffer } from "node:buffer";
|
|
2
|
+
import { BufferView, NonSharedBuffer } from "node:buffer";
|
|
3
3
|
import { Abortable, EventEmitter, InternalEventEmitter } from "node:events";
|
|
4
4
|
import { FileHandle } from "node:fs/promises";
|
|
5
5
|
import * as stream from "node:stream";
|
|
@@ -3029,6 +3029,19 @@ declare module "node:fs" {
|
|
|
3029
3029
|
* If no `options` object is specified, it will default with the above values.
|
|
3030
3030
|
*/
|
|
3031
3031
|
function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadOptions): number;
|
|
3032
|
+
interface ReadFileOptions extends Abortable {
|
|
3033
|
+
encoding?: BufferEncoding | null | undefined;
|
|
3034
|
+
flag?: OpenMode | undefined;
|
|
3035
|
+
}
|
|
3036
|
+
interface ReadFileOptionsWithStringEncoding extends ReadFileOptions {
|
|
3037
|
+
encoding: BufferEncoding;
|
|
3038
|
+
}
|
|
3039
|
+
interface ReadFileOptionsWithBufferEncoding extends ReadFileOptions {
|
|
3040
|
+
encoding?: null | undefined;
|
|
3041
|
+
}
|
|
3042
|
+
interface ReadFileOptionsWithBuffer<T extends NodeJS.ArrayBufferView> extends ReadFileOptionsWithBufferEncoding {
|
|
3043
|
+
buffer: T | ((size: number) => T);
|
|
3044
|
+
}
|
|
3032
3045
|
/**
|
|
3033
3046
|
* Asynchronously reads the entire contents of a file.
|
|
3034
3047
|
*
|
|
@@ -3046,6 +3059,11 @@ declare module "node:fs" {
|
|
|
3046
3059
|
*
|
|
3047
3060
|
* If no encoding is specified, then the raw buffer is returned.
|
|
3048
3061
|
*
|
|
3062
|
+
* If `buffer` is provided and no encoding is specified, the returned `Buffer` is
|
|
3063
|
+
* a view over the supplied buffer containing only the bytes read. If the
|
|
3064
|
+
* supplied buffer is too small to contain the entire file, the callback is
|
|
3065
|
+
* called with an error.
|
|
3066
|
+
*
|
|
3049
3067
|
* If `options` is a string, then it specifies the encoding:
|
|
3050
3068
|
*
|
|
3051
3069
|
* ```js
|
|
@@ -3054,7 +3072,8 @@ declare module "node:fs" {
|
|
|
3054
3072
|
* readFile('/etc/passwd', 'utf8', callback);
|
|
3055
3073
|
* ```
|
|
3056
3074
|
*
|
|
3057
|
-
* When the path is a directory, the behavior of `fs.readFile()` and
|
|
3075
|
+
* When the path is a directory, the behavior of `fs.readFile()` and
|
|
3076
|
+
* `fs.readFileSync()` is platform-specific. On macOS, Linux, and Windows, an
|
|
3058
3077
|
* error will be returned. On FreeBSD, a representation of the directory's contents
|
|
3059
3078
|
* will be returned.
|
|
3060
3079
|
*
|
|
@@ -3092,60 +3111,56 @@ declare module "node:fs" {
|
|
|
3092
3111
|
*
|
|
3093
3112
|
* Aborting an ongoing request does not abort individual operating
|
|
3094
3113
|
* system requests but rather the internal buffering `fs.readFile` performs.
|
|
3114
|
+
*
|
|
3115
|
+
* An example using the `buffer` option with a pre-allocated buffer:
|
|
3116
|
+
*
|
|
3117
|
+
* ```js
|
|
3118
|
+
* import { Buffer } from 'node:buffer';
|
|
3119
|
+
* import { readFile } from 'node:fs';
|
|
3120
|
+
*
|
|
3121
|
+
* const buf = Buffer.alloc(16384);
|
|
3122
|
+
* readFile('/path/to/file', { buffer: buf }, (err, data) => {
|
|
3123
|
+
* if (err) throw err;
|
|
3124
|
+
* console.log(data); // A view over `buf` containing only the bytes read
|
|
3125
|
+
* });
|
|
3126
|
+
* ```
|
|
3127
|
+
*
|
|
3128
|
+
* An example using the `buffer` option with a function returning a buffer:
|
|
3129
|
+
*
|
|
3130
|
+
* ```js
|
|
3131
|
+
* import { Buffer } from 'node:buffer';
|
|
3132
|
+
* import { readFile } from 'node:fs';
|
|
3133
|
+
*
|
|
3134
|
+
* readFile('/path/to/file', {
|
|
3135
|
+
* buffer: (size) => Buffer.alloc(size),
|
|
3136
|
+
* }, (err, data) => {
|
|
3137
|
+
* if (err) throw err;
|
|
3138
|
+
* console.log(data);
|
|
3139
|
+
* });
|
|
3140
|
+
* ```
|
|
3095
3141
|
* @since v0.1.29
|
|
3096
3142
|
* @param path filename or file descriptor
|
|
3097
3143
|
*/
|
|
3144
|
+
function readFile<T extends NodeJS.ArrayBufferView>(
|
|
3145
|
+
path: PathOrFileDescriptor,
|
|
3146
|
+
options: ReadFileOptionsWithBuffer<T>,
|
|
3147
|
+
callback: (err: NodeJS.ErrnoException | null, data: BufferView<T>) => void,
|
|
3148
|
+
): void;
|
|
3098
3149
|
function readFile(
|
|
3099
3150
|
path: PathOrFileDescriptor,
|
|
3100
|
-
options:
|
|
3101
|
-
| ({
|
|
3102
|
-
encoding?: null | undefined;
|
|
3103
|
-
flag?: string | undefined;
|
|
3104
|
-
} & Abortable)
|
|
3105
|
-
| undefined
|
|
3106
|
-
| null,
|
|
3151
|
+
options: ReadFileOptionsWithBufferEncoding | null | undefined,
|
|
3107
3152
|
callback: (err: NodeJS.ErrnoException | null, data: NonSharedBuffer) => void,
|
|
3108
3153
|
): void;
|
|
3109
|
-
/**
|
|
3110
|
-
* Asynchronously reads the entire contents of a file.
|
|
3111
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
3112
|
-
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
3113
|
-
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
3114
|
-
* If a flag is not provided, it defaults to `'r'`.
|
|
3115
|
-
*/
|
|
3116
3154
|
function readFile(
|
|
3117
3155
|
path: PathOrFileDescriptor,
|
|
3118
|
-
options:
|
|
3119
|
-
| ({
|
|
3120
|
-
encoding: BufferEncoding;
|
|
3121
|
-
flag?: string | undefined;
|
|
3122
|
-
} & Abortable)
|
|
3123
|
-
| BufferEncoding,
|
|
3156
|
+
options: ReadFileOptionsWithStringEncoding | BufferEncoding,
|
|
3124
3157
|
callback: (err: NodeJS.ErrnoException | null, data: string) => void,
|
|
3125
3158
|
): void;
|
|
3126
|
-
/**
|
|
3127
|
-
* Asynchronously reads the entire contents of a file.
|
|
3128
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
3129
|
-
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
3130
|
-
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
3131
|
-
* If a flag is not provided, it defaults to `'r'`.
|
|
3132
|
-
*/
|
|
3133
3159
|
function readFile(
|
|
3134
3160
|
path: PathOrFileDescriptor,
|
|
3135
|
-
options:
|
|
3136
|
-
| (ObjectEncodingOptions & {
|
|
3137
|
-
flag?: string | undefined;
|
|
3138
|
-
} & Abortable)
|
|
3139
|
-
| BufferEncoding
|
|
3140
|
-
| undefined
|
|
3141
|
-
| null,
|
|
3161
|
+
options: ReadFileOptions | BufferEncoding | null | undefined,
|
|
3142
3162
|
callback: (err: NodeJS.ErrnoException | null, data: string | NonSharedBuffer) => void,
|
|
3143
3163
|
): void;
|
|
3144
|
-
/**
|
|
3145
|
-
* Asynchronously reads the entire contents of a file.
|
|
3146
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
3147
|
-
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
3148
|
-
*/
|
|
3149
3164
|
function readFile(
|
|
3150
3165
|
path: PathOrFileDescriptor,
|
|
3151
3166
|
callback: (err: NodeJS.ErrnoException | null, data: NonSharedBuffer) => void,
|
|
@@ -3200,16 +3215,37 @@ declare module "node:fs" {
|
|
|
3200
3215
|
| null,
|
|
3201
3216
|
): Promise<string | NonSharedBuffer>;
|
|
3202
3217
|
}
|
|
3218
|
+
interface ReadFileSyncOptions {
|
|
3219
|
+
encoding?: BufferEncoding | null | undefined;
|
|
3220
|
+
flag?: OpenMode | undefined;
|
|
3221
|
+
}
|
|
3222
|
+
interface ReadFileSyncOptionsWithStringEncoding extends ReadFileSyncOptions {
|
|
3223
|
+
encoding: BufferEncoding;
|
|
3224
|
+
}
|
|
3225
|
+
interface ReadFileSyncOptionsWithBufferEncoding extends ReadFileSyncOptions {
|
|
3226
|
+
encoding?: null | undefined;
|
|
3227
|
+
}
|
|
3228
|
+
interface ReadFileSyncOptionsWithBuffer<T extends NodeJS.ArrayBufferView>
|
|
3229
|
+
extends ReadFileSyncOptionsWithBufferEncoding
|
|
3230
|
+
{
|
|
3231
|
+
buffer: T | ((size: number) => T);
|
|
3232
|
+
}
|
|
3203
3233
|
/**
|
|
3204
3234
|
* Returns the contents of the `path`.
|
|
3205
3235
|
*
|
|
3206
3236
|
* For detailed information, see the documentation of the asynchronous version of
|
|
3207
|
-
* this API:
|
|
3237
|
+
* this API: `fs.readFile()`.
|
|
3208
3238
|
*
|
|
3209
3239
|
* If the `encoding` option is specified then this function returns a
|
|
3210
3240
|
* string. Otherwise it returns a buffer.
|
|
3211
3241
|
*
|
|
3212
|
-
*
|
|
3242
|
+
* If `buffer` is provided and no encoding is specified, the returned {Buffer} is
|
|
3243
|
+
* a view over the supplied buffer containing only the bytes read. If the
|
|
3244
|
+
* supplied buffer is too small to contain the entire file, an error will be
|
|
3245
|
+
* thrown.
|
|
3246
|
+
*
|
|
3247
|
+
* Similar to `fs.readFile()`, when the path is a directory, the behavior of
|
|
3248
|
+
* `fs.readFileSync()` is platform-specific.
|
|
3213
3249
|
*
|
|
3214
3250
|
* ```js
|
|
3215
3251
|
* import { readFileSync } from 'node:fs';
|
|
@@ -3224,45 +3260,19 @@ declare module "node:fs" {
|
|
|
3224
3260
|
* @since v0.1.8
|
|
3225
3261
|
* @param path filename or file descriptor
|
|
3226
3262
|
*/
|
|
3263
|
+
function readFileSync<T extends NodeJS.ArrayBufferView>(
|
|
3264
|
+
path: PathOrFileDescriptor,
|
|
3265
|
+
options: ReadFileSyncOptionsWithBuffer<T>,
|
|
3266
|
+
): BufferView<T>;
|
|
3227
3267
|
function readFileSync(
|
|
3228
3268
|
path: PathOrFileDescriptor,
|
|
3229
|
-
options?:
|
|
3230
|
-
encoding?: null | undefined;
|
|
3231
|
-
flag?: string | undefined;
|
|
3232
|
-
} | null,
|
|
3269
|
+
options?: ReadFileSyncOptionsWithBufferEncoding | null,
|
|
3233
3270
|
): NonSharedBuffer;
|
|
3234
|
-
/**
|
|
3235
|
-
* Synchronously reads the entire contents of a file.
|
|
3236
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
3237
|
-
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
3238
|
-
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
3239
|
-
* If a flag is not provided, it defaults to `'r'`.
|
|
3240
|
-
*/
|
|
3241
3271
|
function readFileSync(
|
|
3242
3272
|
path: PathOrFileDescriptor,
|
|
3243
|
-
options:
|
|
3244
|
-
| {
|
|
3245
|
-
encoding: BufferEncoding;
|
|
3246
|
-
flag?: string | undefined;
|
|
3247
|
-
}
|
|
3248
|
-
| BufferEncoding,
|
|
3273
|
+
options: ReadFileSyncOptionsWithStringEncoding | BufferEncoding,
|
|
3249
3274
|
): string;
|
|
3250
|
-
|
|
3251
|
-
* Synchronously reads the entire contents of a file.
|
|
3252
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
3253
|
-
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
3254
|
-
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
3255
|
-
* If a flag is not provided, it defaults to `'r'`.
|
|
3256
|
-
*/
|
|
3257
|
-
function readFileSync(
|
|
3258
|
-
path: PathOrFileDescriptor,
|
|
3259
|
-
options?:
|
|
3260
|
-
| (ObjectEncodingOptions & {
|
|
3261
|
-
flag?: string | undefined;
|
|
3262
|
-
})
|
|
3263
|
-
| BufferEncoding
|
|
3264
|
-
| null,
|
|
3265
|
-
): string | NonSharedBuffer;
|
|
3275
|
+
function readFileSync(path: PathOrFileDescriptor, options: ReadFileSyncOptions): string | NonSharedBuffer;
|
|
3266
3276
|
type WriteFileOptions =
|
|
3267
3277
|
| (
|
|
3268
3278
|
& ObjectEncodingOptions
|
node/http.d.ts
CHANGED
|
@@ -299,7 +299,7 @@ declare module "node:http" {
|
|
|
299
299
|
requireHostHeader?: boolean | undefined;
|
|
300
300
|
/**
|
|
301
301
|
* If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
|
|
302
|
-
* similarly on what is done in `socket.setKeepAlive(
|
|
302
|
+
* similarly on what is done in `socket.setKeepAlive()`.
|
|
303
303
|
* @default false
|
|
304
304
|
* @since v16.5.0
|
|
305
305
|
*/
|
node/http2.d.ts
CHANGED
|
@@ -433,7 +433,7 @@ declare module "node:http2" {
|
|
|
433
433
|
*
|
|
434
434
|
* When the `options.waitForTrailers` option is set, the `'wantTrailers'` event
|
|
435
435
|
* will be emitted immediately after queuing the last chunk of payload data to be
|
|
436
|
-
* sent. The `http2stream.sendTrailers()` method can then be used to
|
|
436
|
+
* sent. The `http2stream.sendTrailers()` method can then be used to send trailing
|
|
437
437
|
* header fields to the peer.
|
|
438
438
|
*
|
|
439
439
|
* When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
|
|
@@ -548,7 +548,7 @@ declare module "node:http2" {
|
|
|
548
548
|
*
|
|
549
549
|
* When the `options.waitForTrailers` option is set, the `'wantTrailers'` event
|
|
550
550
|
* will be emitted immediately after queuing the last chunk of payload data to be
|
|
551
|
-
* sent. The `http2stream.sendTrailers()` method can then be used to
|
|
551
|
+
* sent. The `http2stream.sendTrailers()` method can then be used to send trailing
|
|
552
552
|
* header fields to the peer.
|
|
553
553
|
*
|
|
554
554
|
* When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
|
node/index.d.ts
CHANGED
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
/// <reference path="util.d.ts" />
|
|
109
109
|
/// <reference path="util/types.d.ts" />
|
|
110
110
|
/// <reference path="v8.d.ts" />
|
|
111
|
+
/// <reference path="vfs.d.ts" />
|
|
111
112
|
/// <reference path="vm.d.ts" />
|
|
112
113
|
/// <reference path="wasi.d.ts" />
|
|
113
114
|
/// <reference path="worker_threads.d.ts" />
|
node/inspector.d.ts
CHANGED
|
@@ -43,7 +43,8 @@ declare module "node:inspector" {
|
|
|
43
43
|
*/
|
|
44
44
|
function open(port?: number, host?: string, wait?: boolean): Disposable;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Deactivates the inspector. If there are active connections, they are forcibly
|
|
47
|
+
* terminated. Blocks until the inspector server has fully stopped.
|
|
47
48
|
*/
|
|
48
49
|
function close(): void;
|
|
49
50
|
/**
|
node/net.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ declare module "node:net" {
|
|
|
25
25
|
keepAliveInitialDelay?: number | undefined;
|
|
26
26
|
blockList?: BlockList | undefined;
|
|
27
27
|
typeOfService?: number | undefined;
|
|
28
|
+
handle?: BoundSocket | undefined;
|
|
28
29
|
}
|
|
29
30
|
interface OnReadOpts {
|
|
30
31
|
buffer: Uint8Array | (() => Uint8Array);
|
|
@@ -57,6 +58,12 @@ declare module "node:net" {
|
|
|
57
58
|
}
|
|
58
59
|
type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
|
|
59
60
|
type SocketReadyState = "opening" | "open" | "readOnly" | "writeOnly" | "closed";
|
|
61
|
+
interface SetKeepAliveOptions {
|
|
62
|
+
enable?: boolean | undefined;
|
|
63
|
+
initialDelay?: number | undefined;
|
|
64
|
+
interval?: number | undefined;
|
|
65
|
+
count?: number | undefined;
|
|
66
|
+
}
|
|
60
67
|
interface SocketEventMap extends Omit<stream.DuplexEventMap, "close"> {
|
|
61
68
|
"close": [hadError: boolean];
|
|
62
69
|
"connect": [];
|
|
@@ -199,25 +206,27 @@ declare module "node:net" {
|
|
|
199
206
|
*/
|
|
200
207
|
setNoDelay(noDelay?: boolean): this;
|
|
201
208
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* Set `initialDelay` (in milliseconds) to set the delay between the last
|
|
206
|
-
* data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default
|
|
207
|
-
* (or previous) setting.
|
|
208
|
-
*
|
|
209
|
-
* Enabling the keep-alive functionality will set the following socket options:
|
|
209
|
+
* Configure keep-alive using an options object. See `socket.setKeepAlive()`
|
|
210
|
+
* for a description of each property.
|
|
210
211
|
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
212
|
+
* ```js
|
|
213
|
+
* socket.setKeepAlive({ enable: true, initialDelay: 1000, interval: 1000, count: 10 });
|
|
214
|
+
* ```
|
|
215
|
+
* @since v26.4.0
|
|
216
|
+
* @returns The socket itself.
|
|
217
|
+
*/
|
|
218
|
+
setKeepAlive(options: SetKeepAliveOptions): this;
|
|
219
|
+
/**
|
|
220
|
+
* Configure keep-alive using positional arguments. See
|
|
221
|
+
* `socket.setKeepAlive()` for a description of each argument.
|
|
215
222
|
* @since v0.1.92
|
|
216
|
-
* @param
|
|
217
|
-
* @param
|
|
218
|
-
* @
|
|
223
|
+
* @param enable **Default:** `false`
|
|
224
|
+
* @param initialDelay **Default:** `0`
|
|
225
|
+
* @param interval **Default:** `1000`
|
|
226
|
+
* @param count **Default:** `10`
|
|
227
|
+
* @returns The socket itself.
|
|
219
228
|
*/
|
|
220
|
-
setKeepAlive(enable?: boolean, initialDelay?: number): this;
|
|
229
|
+
setKeepAlive(enable?: boolean, initialDelay?: number, interval?: number, count?: number): this;
|
|
221
230
|
/**
|
|
222
231
|
* Returns the current Type of Service (TOS) field for IPv4 packets or Traffic
|
|
223
232
|
* Class for IPv6 packets for this socket.
|
|
@@ -442,9 +451,92 @@ declare module "node:net" {
|
|
|
442
451
|
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
443
452
|
// #endregion
|
|
444
453
|
}
|
|
454
|
+
interface BoundSocketOptions {
|
|
455
|
+
/**
|
|
456
|
+
* Local address to bind. Must be a numeric IP literal; no DNS
|
|
457
|
+
* resolution is performed. **Default:** `'0.0.0.0'`, or `'::'` when
|
|
458
|
+
* `ipv6Only` is `true`.
|
|
459
|
+
*/
|
|
460
|
+
host?: string | undefined;
|
|
461
|
+
/**
|
|
462
|
+
* Local port. `0` requests an OS-assigned ephemeral port.
|
|
463
|
+
* **Default:** `0`.
|
|
464
|
+
*/
|
|
465
|
+
port?: number | undefined;
|
|
466
|
+
/**
|
|
467
|
+
* Sets `IPV6_V6ONLY`, disabling dual-stack support so the
|
|
468
|
+
* socket binds IPv6 only. Only meaningful for IPv6 binds. **Default:**
|
|
469
|
+
* `false`.
|
|
470
|
+
*/
|
|
471
|
+
ipv6Only?: boolean | undefined;
|
|
472
|
+
/**
|
|
473
|
+
* Sets `SO_REUSEPORT`, allowing multiple sockets to bind
|
|
474
|
+
* the same address and port for kernel-level load balancing. Support is
|
|
475
|
+
* platform-dependent. **Default:** `false`.
|
|
476
|
+
*/
|
|
477
|
+
reusePort?: boolean | undefined;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Allows for the synchronous creation of a pre-bound socket, that can be passed
|
|
481
|
+
* to `listen()` or `new net.Socket()` later on. For `listen()` this enables
|
|
482
|
+
* synchronous port reservation, while for `new net.Socket()`, it allows control
|
|
483
|
+
* over the local egress port/IP, via `bind(2)` semantics.
|
|
484
|
+
*
|
|
485
|
+
* Adoption transfers ownership of the socket; afterwards `address()` and `close()`
|
|
486
|
+
* throw `ERR_SOCKET_HANDLE_ADOPTED`. A handle that is never adopted must be
|
|
487
|
+
* closed to avoid leaking the socket.
|
|
488
|
+
*
|
|
489
|
+
* ```js
|
|
490
|
+
* import net from 'node:net';
|
|
491
|
+
*
|
|
492
|
+
* const bound = new net.BoundSocket();
|
|
493
|
+
* const { port } = bound.address();
|
|
494
|
+
* console.log(`Reserved port ${port} for server`);
|
|
495
|
+
*
|
|
496
|
+
* const server = net.createServer();
|
|
497
|
+
* server.listen(bound); // Adopt as a server, or pass to new net.Socket() instead.
|
|
498
|
+
* ```
|
|
499
|
+
* @since v26.4.0
|
|
500
|
+
*/
|
|
501
|
+
class BoundSocket {
|
|
502
|
+
/**
|
|
503
|
+
* @since v26.4.0
|
|
504
|
+
*/
|
|
505
|
+
constructor(options?: BoundSocketOptions);
|
|
506
|
+
/**
|
|
507
|
+
* Returns the bound local address. When bound with `port: 0`, `port` is the
|
|
508
|
+
* OS-assigned ephemeral port.
|
|
509
|
+
* @since v26.4.0
|
|
510
|
+
* @returns An object with `address`, `family`, and `port` properties,
|
|
511
|
+
* as `server.address()` returns.
|
|
512
|
+
*/
|
|
513
|
+
address(): AddressInfo;
|
|
514
|
+
/**
|
|
515
|
+
* Returns the file descriptor of the bound socket. Ownership remains with the
|
|
516
|
+
* `BoundSocket`, so the descriptor must not be closed by the caller. The
|
|
517
|
+
* descriptor is only available before the handle is adopted; afterwards it belongs
|
|
518
|
+
* to the adopting `net.Server` or `net.Socket` and `fd()` throws
|
|
519
|
+
* `ERR_SOCKET_HANDLE_ADOPTED`.
|
|
520
|
+
* @since v26.4.0
|
|
521
|
+
* @returns The underlying OS file descriptor, or `-1` on platforms
|
|
522
|
+
* that do not expose one for sockets (such as Windows).
|
|
523
|
+
*/
|
|
524
|
+
fd(): number;
|
|
525
|
+
/**
|
|
526
|
+
* Releases the bound socket. Only needed when the handle is never adopted.
|
|
527
|
+
* @since v26.4.0
|
|
528
|
+
*/
|
|
529
|
+
close(): void;
|
|
530
|
+
/**
|
|
531
|
+
* Closes the handle if it has not been adopted or closed; otherwise a no-op.
|
|
532
|
+
* @since v26.4.0
|
|
533
|
+
*/
|
|
534
|
+
[Symbol.dispose](): void;
|
|
535
|
+
}
|
|
445
536
|
interface ListenOptions extends Abortable {
|
|
446
537
|
backlog?: number | undefined;
|
|
447
538
|
exclusive?: boolean | undefined;
|
|
539
|
+
handle?: BoundSocket | undefined;
|
|
448
540
|
host?: string | undefined;
|
|
449
541
|
/**
|
|
450
542
|
* @default false
|
node/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.4.1",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -150,6 +150,6 @@
|
|
|
150
150
|
"undici-types": "~8.3.0"
|
|
151
151
|
},
|
|
152
152
|
"peerDependencies": {},
|
|
153
|
-
"typesPublisherContentHash": "
|
|
153
|
+
"typesPublisherContentHash": "463ff626c280fc7ad82097e8ff9ab6bd4a19fb2b4c56c8d56c2b8148cd872d0c",
|
|
154
154
|
"typeScriptVersion": "5.6"
|
|
155
155
|
}
|
node/quic.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
declare module "node:quic" {
|
|
2
2
|
import { NonSharedBuffer } from "node:buffer";
|
|
3
|
-
import { KeyObject } from "node:crypto";
|
|
3
|
+
import { KeyObject, X509Certificate } from "node:crypto";
|
|
4
4
|
import { FileHandle } from "node:fs/promises";
|
|
5
5
|
import { BlockList, SocketAddress } from "node:net";
|
|
6
6
|
import { Writer } from "node:stream/iter";
|
|
7
|
-
import { EphemeralKeyInfo
|
|
7
|
+
import { EphemeralKeyInfo } from "node:tls";
|
|
8
8
|
/**
|
|
9
9
|
* @since v23.8.0
|
|
10
10
|
*/
|
|
@@ -25,6 +25,10 @@ declare module "node:quic" {
|
|
|
25
25
|
id: bigint,
|
|
26
26
|
status: "acknowledged" | "lost" | "abandoned",
|
|
27
27
|
) => void;
|
|
28
|
+
/**
|
|
29
|
+
* @since v23.8.0
|
|
30
|
+
*/
|
|
31
|
+
type OnApplicationCallback = (this: QuicSession, applicationoptions: SessionApplicationOptions) => void;
|
|
28
32
|
/**
|
|
29
33
|
* @since v23.8.0
|
|
30
34
|
*/
|
|
@@ -235,6 +239,7 @@ declare module "node:quic" {
|
|
|
235
239
|
*/
|
|
236
240
|
enableDatagrams?: boolean | undefined;
|
|
237
241
|
}
|
|
242
|
+
type SessionApplicationOptions = { [K in keyof ApplicationOptions]-?: ApplicationOptions[K] & (bigint | boolean) };
|
|
238
243
|
/**
|
|
239
244
|
* @since v23.8.0
|
|
240
245
|
*/
|
|
@@ -539,6 +544,7 @@ declare module "node:quic" {
|
|
|
539
544
|
ongoaway?: QuicSession["ongoaway"] | undefined;
|
|
540
545
|
onkeylog?: QuicSession["onkeylog"] | undefined;
|
|
541
546
|
onqlog?: QuicSession["onqlog"] | undefined;
|
|
547
|
+
onapplication?: QuicSession["onapplication"] | undefined;
|
|
542
548
|
onheaders?: QuicStream["onheaders"] | undefined;
|
|
543
549
|
ontrailers?: QuicStream["ontrailers"] | undefined;
|
|
544
550
|
oninfo?: QuicStream["oninfo"] | undefined;
|
|
@@ -608,6 +614,20 @@ declare module "node:quic" {
|
|
|
608
614
|
* @since v23.8.0
|
|
609
615
|
*/
|
|
610
616
|
function listen(onsession: OnSessionCallback, options?: SessionOptions): Promise<QuicEndpoint>;
|
|
617
|
+
interface ListEndpointsOptions {
|
|
618
|
+
/**
|
|
619
|
+
* If `true` (the default), only returns endpoints that are
|
|
620
|
+
* active (not destroyed, not closing, and not busy). If `false` returns all
|
|
621
|
+
* endpoints.
|
|
622
|
+
*/
|
|
623
|
+
active?: boolean | undefined;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Returns the list of all `QuicEndpoint` instances. By default, only active
|
|
627
|
+
* endpoints are returned.
|
|
628
|
+
* @since v26.4.0
|
|
629
|
+
*/
|
|
630
|
+
function listEndpoints(options?: ListEndpointsOptions): QuicEndpoint[];
|
|
611
631
|
/**
|
|
612
632
|
* The endpoint configuration options passed when constructing a new `QuicEndpoint` instance.
|
|
613
633
|
* @since v23.8.0
|
|
@@ -1172,7 +1192,7 @@ declare module "node:quic" {
|
|
|
1172
1192
|
* be negotiated separately from the transport parameters. Read only.
|
|
1173
1193
|
* @since v26.3.0
|
|
1174
1194
|
*/
|
|
1175
|
-
readonly applicationOptions:
|
|
1195
|
+
readonly applicationOptions: SessionApplicationOptions;
|
|
1176
1196
|
/**
|
|
1177
1197
|
* Initiate a graceful close of the session. Existing streams will be allowed
|
|
1178
1198
|
* to complete but no new streams will be opened. Once all streams have closed,
|
|
@@ -1226,6 +1246,11 @@ declare module "node:quic" {
|
|
|
1226
1246
|
* @since v23.8.0
|
|
1227
1247
|
*/
|
|
1228
1248
|
readonly endpoint: QuicEndpoint | null;
|
|
1249
|
+
/**
|
|
1250
|
+
* The callback to invoke when new application options, e.g. HTTP/3 settings arrived.
|
|
1251
|
+
* @since v26.4
|
|
1252
|
+
*/
|
|
1253
|
+
onapplication: OnApplicationCallback | undefined;
|
|
1229
1254
|
/**
|
|
1230
1255
|
* An optional callback invoked when the session is destroyed with an error.
|
|
1231
1256
|
* This includes errors caused by user callbacks that throw or reject (see
|
|
@@ -1412,19 +1437,20 @@ declare module "node:quic" {
|
|
|
1412
1437
|
encoding?: BufferEncoding,
|
|
1413
1438
|
): Promise<bigint>;
|
|
1414
1439
|
/**
|
|
1415
|
-
* The local certificate as
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
1440
|
+
* The local certificate as a `crypto.X509Certificate` instance. Server
|
|
1441
|
+
* sessions return the certificate configured for the negotiated SNI host.
|
|
1442
|
+
* Client sessions return `undefined` unless a client certificate was sent.
|
|
1443
|
+
* Returns `undefined` if the session is destroyed.
|
|
1418
1444
|
* @since v26.2.0
|
|
1419
1445
|
*/
|
|
1420
|
-
readonly certificate:
|
|
1446
|
+
readonly certificate: X509Certificate | undefined;
|
|
1421
1447
|
/**
|
|
1422
|
-
* The peer's certificate as
|
|
1423
|
-
* `
|
|
1424
|
-
*
|
|
1448
|
+
* The peer's certificate as a `crypto.X509Certificate` instance. Returns
|
|
1449
|
+
* `undefined` if the peer did not present a certificate or the session is
|
|
1450
|
+
* destroyed.
|
|
1425
1451
|
* @since v26.2.0
|
|
1426
1452
|
*/
|
|
1427
|
-
readonly peerCertificate:
|
|
1453
|
+
readonly peerCertificate: X509Certificate | undefined;
|
|
1428
1454
|
/**
|
|
1429
1455
|
* The ephemeral key information for the session, with properties such as
|
|
1430
1456
|
* `type`, `name`, and `size`. Only available on client sessions. Returns
|
node/stream/iter.d.ts
CHANGED
|
@@ -271,8 +271,8 @@ declare module "node:stream/iter" {
|
|
|
271
271
|
*
|
|
272
272
|
* If the object implements the `toAsyncStreamable` protocol (as
|
|
273
273
|
* `stream.Readable` does), that protocol is used. Otherwise, the function
|
|
274
|
-
* duck-types on `read()` and `
|
|
275
|
-
* a batched async iterator.
|
|
274
|
+
* duck-types on `read()`, `on()`, and `off()` (EventEmitter) and wraps the
|
|
275
|
+
* stream with a batched async iterator.
|
|
276
276
|
*
|
|
277
277
|
* The result is cached per instance -- calling `fromReadable()` twice with the
|
|
278
278
|
* same stream returns the same iterable.
|
|
@@ -294,7 +294,7 @@ declare module "node:stream/iter" {
|
|
|
294
294
|
* @since v26.1.0
|
|
295
295
|
* @experimental
|
|
296
296
|
* @param readable A classic Readable stream or any object
|
|
297
|
-
* with `read()` and `
|
|
297
|
+
* with `read()`, `on()` and `off()` methods.
|
|
298
298
|
* @returns A stream/iter async iterable source.
|
|
299
299
|
*/
|
|
300
300
|
function fromReadable(readable: NodeJS.ReadableStream): ByteReadableStream;
|
|
@@ -389,7 +389,7 @@ declare module "node:stream/iter" {
|
|
|
389
389
|
*
|
|
390
390
|
* Each `_write()` / `_writev()` call attempts the Writer's synchronous method
|
|
391
391
|
* first (`writeSync` / `writevSync`), falling back to the async method if the
|
|
392
|
-
* sync path returns `false
|
|
392
|
+
* sync path returns `false`. Similarly, `_final()` tries `endSync()`
|
|
393
393
|
* before `end()`. When the sync path succeeds, the callback is deferred via
|
|
394
394
|
* `queueMicrotask` to preserve the async resolution contract.
|
|
395
395
|
*
|
node/tls.d.ts
CHANGED
|
@@ -746,6 +746,7 @@ declare module "node:tls" {
|
|
|
746
746
|
// #endregion
|
|
747
747
|
}
|
|
748
748
|
type SecureVersion = "TLSv1.3" | "TLSv1.2" | "TLSv1.1" | "TLSv1";
|
|
749
|
+
type CertificateCompressionAlgorithm = "zlib" | "brotli" | "zstd";
|
|
749
750
|
interface SecureContextOptions {
|
|
750
751
|
/**
|
|
751
752
|
* If set, this will be called when a client opens a connection using the ALPN extension.
|
|
@@ -782,6 +783,15 @@ declare module "node:tls" {
|
|
|
782
783
|
* able to validate the certificate, and the handshake will fail.
|
|
783
784
|
*/
|
|
784
785
|
cert?: string | Buffer | Array<string | Buffer> | undefined;
|
|
786
|
+
/**
|
|
787
|
+
* An array of supported certificate
|
|
788
|
+
* compression algorithm names, in preference order. Supported values are
|
|
789
|
+
* `'zlib'`, `'brotli'`, and `'zstd'`. When set, enables TLS certificate
|
|
790
|
+
* compression ([RFC 8879](https://tools.ietf.org/html/rfc8879)) which compresses certificates during the TLS
|
|
791
|
+
* handshake, reducing handshake size. Only effective with TLSv1.3.
|
|
792
|
+
* **Default:** `[]` (disabled).
|
|
793
|
+
*/
|
|
794
|
+
certificateCompression?: readonly CertificateCompressionAlgorithm[] | undefined;
|
|
785
795
|
/**
|
|
786
796
|
* Colon-separated list of supported signature algorithms. The list
|
|
787
797
|
* can contain digest algorithms (SHA256, MD5 etc.), public key
|
|
@@ -1110,6 +1120,20 @@ declare module "node:tls" {
|
|
|
1110
1120
|
* @since v0.10.2
|
|
1111
1121
|
*/
|
|
1112
1122
|
function getCiphers(): string[];
|
|
1123
|
+
/**
|
|
1124
|
+
* Returns an array with the names of the RFC 8879 certificate compression
|
|
1125
|
+
* algorithms supported by the current OpenSSL build, suitable for use in the
|
|
1126
|
+
* `certificateCompression` option of `tls.createSecureContext()`. Possible
|
|
1127
|
+
* values include `'zlib'`, `'brotli'`, and `'zstd'`.
|
|
1128
|
+
*
|
|
1129
|
+
* The array is empty when certificate compression is unavailable.
|
|
1130
|
+
*
|
|
1131
|
+
* ```js
|
|
1132
|
+
* console.log(tls.getCertificateCompressionAlgorithms()); // ['zlib', 'brotli', 'zstd']
|
|
1133
|
+
* ```
|
|
1134
|
+
* @since v26.4.0
|
|
1135
|
+
*/
|
|
1136
|
+
function getCertificateCompressionAlgorithms(): CertificateCompressionAlgorithm[];
|
|
1113
1137
|
/**
|
|
1114
1138
|
* Sets the default CA certificates used by Node.js TLS clients. If the provided
|
|
1115
1139
|
* certificates are parsed successfully, they will become the default CA
|
node/ts5.6/buffer.buffer.d.ts
CHANGED
|
@@ -459,4 +459,9 @@ declare module "node:buffer" {
|
|
|
459
459
|
*/
|
|
460
460
|
type AllowSharedBuffer = Buffer;
|
|
461
461
|
}
|
|
462
|
+
/**
|
|
463
|
+
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
|
|
464
|
+
* TypeScript versions earlier than 5.7.
|
|
465
|
+
*/
|
|
466
|
+
type BufferView<T extends NodeJS.ArrayBufferView> = Buffer;
|
|
462
467
|
}
|
node/ts5.6/index.d.ts
CHANGED
|
@@ -110,6 +110,7 @@
|
|
|
110
110
|
/// <reference path="../util.d.ts" />
|
|
111
111
|
/// <reference path="../util/types.d.ts" />
|
|
112
112
|
/// <reference path="../v8.d.ts" />
|
|
113
|
+
/// <reference path="../vfs.d.ts" />
|
|
113
114
|
/// <reference path="../vm.d.ts" />
|
|
114
115
|
/// <reference path="../wasi.d.ts" />
|
|
115
116
|
/// <reference path="../worker_threads.d.ts" />
|
node/ts5.7/index.d.ts
CHANGED
|
@@ -110,6 +110,7 @@
|
|
|
110
110
|
/// <reference path="../util.d.ts" />
|
|
111
111
|
/// <reference path="../util/types.d.ts" />
|
|
112
112
|
/// <reference path="../v8.d.ts" />
|
|
113
|
+
/// <reference path="../vfs.d.ts" />
|
|
113
114
|
/// <reference path="../vm.d.ts" />
|
|
114
115
|
/// <reference path="../wasi.d.ts" />
|
|
115
116
|
/// <reference path="../worker_threads.d.ts" />
|
node/tty.d.ts
CHANGED
|
@@ -28,10 +28,11 @@ declare module "node:tty" {
|
|
|
28
28
|
* Allows configuration of `tty.ReadStream` so that it operates as a raw device.
|
|
29
29
|
*
|
|
30
30
|
* When in raw mode, input is always available character-by-character, not
|
|
31
|
-
* including modifiers. Additionally, all special processing of characters
|
|
32
|
-
* terminal is disabled, including echoing input
|
|
31
|
+
* including modifiers. Additionally, all special processing of input characters
|
|
32
|
+
* by the terminal is disabled, including echoing input
|
|
33
33
|
* characters. Ctrl+C will no longer cause a `SIGINT` when
|
|
34
|
-
* in this mode.
|
|
34
|
+
* in this mode. This mode does not affect terminal output processing, such as
|
|
35
|
+
* newline translation on Unix terminals.
|
|
35
36
|
* @since v0.7.7
|
|
36
37
|
* @param mode If `true`, configures the `tty.ReadStream` to operate as a raw device. If `false`, configures the `tty.ReadStream` to operate in its default mode. The `readStream.isRaw`
|
|
37
38
|
* property will be set to the resulting mode.
|
node/vfs.d.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
declare module "node:vfs" {
|
|
2
|
+
/**
|
|
3
|
+
* Convenience factory equivalent to `new VirtualFileSystem(provider, options)`.
|
|
4
|
+
*
|
|
5
|
+
* ```js
|
|
6
|
+
* const vfs = require('node:vfs');
|
|
7
|
+
*
|
|
8
|
+
* // Default in-memory provider
|
|
9
|
+
* const memoryVfs = vfs.create();
|
|
10
|
+
*
|
|
11
|
+
* // Explicit provider
|
|
12
|
+
* const realVfs = vfs.create(new vfs.RealFSProvider('/tmp/sandbox'));
|
|
13
|
+
* ```
|
|
14
|
+
* @since v26.4.0
|
|
15
|
+
* @param provider The provider to use. **Default:** `new MemoryProvider()`.
|
|
16
|
+
*/
|
|
17
|
+
function create(provider?: VirtualProvider, options?: VirtualFileSystemOptions): VirtualFileSystem;
|
|
18
|
+
function create(options: VirtualFileSystemOptions): VirtualFileSystem;
|
|
19
|
+
interface VirtualFileSystemOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Whether to emit the experimental warning. **Default:** `true`.
|
|
22
|
+
*/
|
|
23
|
+
emitExperimentalWarning?: boolean | undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A `VirtualFileSystem` wraps a {@link VirtualProvider} and exposes a
|
|
27
|
+
* `node:fs`-like API. Each instance maintains its own file tree.
|
|
28
|
+
* @since v26.4.0
|
|
29
|
+
*/
|
|
30
|
+
class VirtualFileSystem {
|
|
31
|
+
/**
|
|
32
|
+
* @param provider The provider to use. **Default:** `new MemoryProvider()`.
|
|
33
|
+
*/
|
|
34
|
+
constructor(provider?: VirtualProvider, options?: VirtualFileSystemOptions);
|
|
35
|
+
constructor(options: VirtualFileSystemOptions);
|
|
36
|
+
/**
|
|
37
|
+
* The provider backing this VFS instance.
|
|
38
|
+
* @since v26.4.0
|
|
39
|
+
*/
|
|
40
|
+
readonly provider: VirtualProvider;
|
|
41
|
+
/**
|
|
42
|
+
* `true` when the underlying provider is read-only.
|
|
43
|
+
* @since v26.4.0
|
|
44
|
+
*/
|
|
45
|
+
readonly readonly: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface VirtualFileSystem extends
|
|
48
|
+
// Synchronous API
|
|
49
|
+
Pick<
|
|
50
|
+
typeof import("node:fs"),
|
|
51
|
+
| "existsSync"
|
|
52
|
+
| "statSync"
|
|
53
|
+
| "lstatSync"
|
|
54
|
+
| "readFileSync"
|
|
55
|
+
| "writeFileSync"
|
|
56
|
+
| "appendFileSync"
|
|
57
|
+
| "readdirSync"
|
|
58
|
+
| "mkdirSync"
|
|
59
|
+
| "rmdirSync"
|
|
60
|
+
| "unlinkSync"
|
|
61
|
+
| "renameSync"
|
|
62
|
+
| "copyFileSync"
|
|
63
|
+
| "realpathSync"
|
|
64
|
+
| "readlinkSync"
|
|
65
|
+
| "symlinkSync"
|
|
66
|
+
| "accessSync"
|
|
67
|
+
| "rmSync"
|
|
68
|
+
| "truncateSync"
|
|
69
|
+
| "ftruncateSync"
|
|
70
|
+
| "linkSync"
|
|
71
|
+
| "chmodSync"
|
|
72
|
+
| "chownSync"
|
|
73
|
+
| "utimesSync"
|
|
74
|
+
| "lutimesSync"
|
|
75
|
+
| "mkdtempSync"
|
|
76
|
+
| "opendirSync"
|
|
77
|
+
| "openAsBlob"
|
|
78
|
+
| "openSync"
|
|
79
|
+
| "closeSync"
|
|
80
|
+
| "readSync"
|
|
81
|
+
| "writeSync"
|
|
82
|
+
| "fstatSync"
|
|
83
|
+
| "createReadStream"
|
|
84
|
+
| "createWriteStream"
|
|
85
|
+
| "watch"
|
|
86
|
+
| "watchFile"
|
|
87
|
+
| "unwatchFile"
|
|
88
|
+
>,
|
|
89
|
+
// Callback API
|
|
90
|
+
Pick<
|
|
91
|
+
typeof import("node:fs"),
|
|
92
|
+
| "readFile"
|
|
93
|
+
| "writeFile"
|
|
94
|
+
| "stat"
|
|
95
|
+
| "lstat"
|
|
96
|
+
| "readdir"
|
|
97
|
+
| "realpath"
|
|
98
|
+
| "readlink"
|
|
99
|
+
| "access"
|
|
100
|
+
| "open"
|
|
101
|
+
| "close"
|
|
102
|
+
| "read"
|
|
103
|
+
| "write"
|
|
104
|
+
| "rm"
|
|
105
|
+
| "fstat"
|
|
106
|
+
| "truncate"
|
|
107
|
+
| "ftruncate"
|
|
108
|
+
| "link"
|
|
109
|
+
| "mkdtemp"
|
|
110
|
+
| "opendir"
|
|
111
|
+
>
|
|
112
|
+
{
|
|
113
|
+
// Promise API
|
|
114
|
+
readonly promises: Pick<
|
|
115
|
+
typeof import("node:fs/promises"),
|
|
116
|
+
| "readFile"
|
|
117
|
+
| "writeFile"
|
|
118
|
+
| "appendFile"
|
|
119
|
+
| "stat"
|
|
120
|
+
| "lstat"
|
|
121
|
+
| "readdir"
|
|
122
|
+
| "mkdir"
|
|
123
|
+
| "rmdir"
|
|
124
|
+
| "unlink"
|
|
125
|
+
| "rename"
|
|
126
|
+
| "copyFile"
|
|
127
|
+
| "realpath"
|
|
128
|
+
| "readlink"
|
|
129
|
+
| "symlink"
|
|
130
|
+
| "access"
|
|
131
|
+
| "rm"
|
|
132
|
+
| "truncate"
|
|
133
|
+
| "link"
|
|
134
|
+
| "mkdtemp"
|
|
135
|
+
| "chmod"
|
|
136
|
+
| "chown"
|
|
137
|
+
| "lchown"
|
|
138
|
+
| "utimes"
|
|
139
|
+
| "lutimes"
|
|
140
|
+
| "open"
|
|
141
|
+
| "lchmod"
|
|
142
|
+
| "watch"
|
|
143
|
+
>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The base class for all VFS providers. Subclasses implement the essential
|
|
147
|
+
* primitives (such as `open`, `stat`, `readdir`, `mkdir`, `rmdir`, `unlink`,
|
|
148
|
+
* `rename`, etc.) and inherit default implementations of the derived
|
|
149
|
+
* methods (such as `readFile`, `writeFile`, `exists`, `copyFile`, `access`, etc.).
|
|
150
|
+
* @since v26.4.0
|
|
151
|
+
*/
|
|
152
|
+
abstract class VirtualProvider {
|
|
153
|
+
get readonly(): boolean;
|
|
154
|
+
get supportsSymlinks(): boolean;
|
|
155
|
+
get supportsWatch(): boolean;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The default in-memory provider. Stores files, directories, and symbolic
|
|
159
|
+
* links in a `Map`-backed tree, supports symlinks (`supportsSymlinks ===
|
|
160
|
+
* true`), and supports watching (`supportsWatch === true`).
|
|
161
|
+
* @since v26.4.0
|
|
162
|
+
*/
|
|
163
|
+
class MemoryProvider extends VirtualProvider {
|
|
164
|
+
/**
|
|
165
|
+
* Locks the provider into read-only mode. Subsequent writes through any
|
|
166
|
+
* `VirtualFileSystem` using this provider throw `EROFS`. There is no
|
|
167
|
+
* way to revert the provider to writable.
|
|
168
|
+
*
|
|
169
|
+
* ```js
|
|
170
|
+
* const vfs = require('node:vfs');
|
|
171
|
+
*
|
|
172
|
+
* const provider = new vfs.MemoryProvider();
|
|
173
|
+
* const myVfs = vfs.create(provider);
|
|
174
|
+
* myVfs.writeFileSync('/seed.txt', 'initial');
|
|
175
|
+
*
|
|
176
|
+
* provider.setReadOnly();
|
|
177
|
+
*
|
|
178
|
+
* myVfs.writeFileSync('/x.txt', 'fail'); // throws EROFS
|
|
179
|
+
* ```
|
|
180
|
+
* @since v26.4.0
|
|
181
|
+
*/
|
|
182
|
+
setReadOnly(): void;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A provider that wraps a directory (i.e. one on the actual file system) and exposes its
|
|
186
|
+
* contents through the VFS API. All VFS paths are resolved relative to
|
|
187
|
+
* the root and verified to stay inside it; symbolic links resolving
|
|
188
|
+
* outside the root are rejected.
|
|
189
|
+
* @since v26.4.0
|
|
190
|
+
*/
|
|
191
|
+
class RealFSProvider extends VirtualProvider {
|
|
192
|
+
/**
|
|
193
|
+
* ```js
|
|
194
|
+
* const vfs = require('node:vfs');
|
|
195
|
+
*
|
|
196
|
+
* const realVfs = vfs.create(new vfs.RealFSProvider('/tmp/sandbox'));
|
|
197
|
+
* realVfs.writeFileSync('/file.txt', 'hello'); // writes /tmp/sandbox/file.txt
|
|
198
|
+
* ```
|
|
199
|
+
* @since v26.4.0
|
|
200
|
+
* @param rootPath The absolute file-system path to use as the root.
|
|
201
|
+
* Must be a non-empty string.
|
|
202
|
+
*/
|
|
203
|
+
constructor(rootPath: string);
|
|
204
|
+
/**
|
|
205
|
+
* The resolved absolute path used as the root.
|
|
206
|
+
* @since v26.4.0
|
|
207
|
+
*/
|
|
208
|
+
readonly rootPath: string;
|
|
209
|
+
}
|
|
210
|
+
}
|
node/vm.d.ts
CHANGED
|
@@ -741,7 +741,7 @@ declare module "node:vm" {
|
|
|
741
741
|
*/
|
|
742
742
|
status: ModuleStatus;
|
|
743
743
|
/**
|
|
744
|
-
* Evaluate the module and its
|
|
744
|
+
* Evaluate the module and its dependencies. Corresponds to the [Evaluate() concrete method](https://tc39.es/ecma262/#sec-moduleevaluation) field of
|
|
745
745
|
* [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records)s in the ECMAScript specification.
|
|
746
746
|
*
|
|
747
747
|
* If the module is a `vm.SourceTextModule`, `evaluate()` must be called after the module has been instantiated;
|