@types/node 20.0.0 → 20.1.0
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/assert.d.ts +4 -3
- node/async_hooks.d.ts +1 -1
- node/buffer.d.ts +6 -6
- node/child_process.d.ts +1 -1
- node/cluster.d.ts +1 -1
- node/console.d.ts +1 -1
- node/crypto.d.ts +1 -1
- node/dgram.d.ts +1 -1
- node/diagnostics_channel.d.ts +1 -1
- node/dns.d.ts +9 -1
- node/domain.d.ts +2 -2
- node/events.d.ts +1 -1
- node/fs/promises.d.ts +4 -0
- node/fs.d.ts +27 -1
- node/http.d.ts +12 -4
- node/http2.d.ts +1 -1
- node/https.d.ts +1 -1
- node/index.d.ts +1 -1
- node/inspector.d.ts +1 -1
- node/net.d.ts +1 -1
- node/os.d.ts +1 -1
- node/package.json +2 -2
- node/path.d.ts +1 -1
- node/perf_hooks.d.ts +1 -1
- node/punycode.d.ts +1 -1
- node/querystring.d.ts +1 -1
- node/readline.d.ts +1 -1
- node/repl.d.ts +1 -1
- node/stream.d.ts +15 -1
- node/string_decoder.d.ts +1 -1
- node/test.d.ts +423 -110
- node/timers.d.ts +1 -1
- node/tls.d.ts +3 -2
- node/trace_events.d.ts +1 -1
- node/ts4.8/assert.d.ts +5 -4
- node/ts4.8/async_hooks.d.ts +5 -13
- node/ts4.8/buffer.d.ts +6 -6
- node/ts4.8/child_process.d.ts +1 -1
- node/ts4.8/cluster.d.ts +1 -1
- node/ts4.8/console.d.ts +1 -1
- node/ts4.8/crypto.d.ts +1 -1
- node/ts4.8/dgram.d.ts +1 -1
- node/ts4.8/diagnostics_channel.d.ts +1 -1
- node/ts4.8/dns.d.ts +9 -1
- node/ts4.8/domain.d.ts +2 -2
- node/ts4.8/events.d.ts +1 -1
- node/ts4.8/fs/promises.d.ts +24 -0
- node/ts4.8/fs.d.ts +123 -1
- node/ts4.8/globals.d.ts +29 -28
- node/ts4.8/http.d.ts +67 -2
- node/ts4.8/http2.d.ts +1 -1
- node/ts4.8/https.d.ts +1 -1
- node/ts4.8/inspector.d.ts +1 -1
- node/ts4.8/net.d.ts +7 -7
- node/ts4.8/os.d.ts +1 -1
- node/ts4.8/path.d.ts +1 -1
- node/ts4.8/perf_hooks.d.ts +1 -1
- node/ts4.8/punycode.d.ts +1 -1
- node/ts4.8/querystring.d.ts +1 -1
- node/ts4.8/readline.d.ts +1 -1
- node/ts4.8/repl.d.ts +1 -1
- node/ts4.8/stream.d.ts +15 -1
- node/ts4.8/string_decoder.d.ts +1 -1
- node/ts4.8/test.d.ts +423 -111
- node/ts4.8/timers.d.ts +8 -1
- node/ts4.8/tls.d.ts +3 -2
- node/ts4.8/trace_events.d.ts +1 -1
- node/ts4.8/tty.d.ts +1 -1
- node/ts4.8/url.d.ts +1 -1
- node/ts4.8/util.d.ts +2 -2
- node/ts4.8/v8.d.ts +4 -1
- node/ts4.8/vm.d.ts +1 -1
- node/ts4.8/wasi.d.ts +6 -6
- node/ts4.8/worker_threads.d.ts +1 -1
- node/ts4.8/zlib.d.ts +1 -1
- node/tty.d.ts +1 -1
- node/url.d.ts +1 -1
- node/util.d.ts +2 -2
- node/v8.d.ts +1 -1
- node/vm.d.ts +1 -1
- node/wasi.d.ts +6 -6
- node/worker_threads.d.ts +1 -1
- node/zlib.d.ts +1 -1
node/timers.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* The timer functions within Node.js implement a similar API as the timers API
|
|
7
7
|
* provided by Web Browsers but use a different internal implementation that is
|
|
8
8
|
* built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout).
|
|
9
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
9
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/timers.js)
|
|
10
10
|
*/
|
|
11
11
|
declare module 'timers' {
|
|
12
12
|
import { Abortable } from 'node:events';
|
node/tls.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* ```js
|
|
7
7
|
* const tls = require('node:tls');
|
|
8
8
|
* ```
|
|
9
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
9
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/tls.js)
|
|
10
10
|
*/
|
|
11
11
|
declare module 'tls' {
|
|
12
12
|
import { X509Certificate } from 'node:crypto';
|
|
@@ -637,7 +637,8 @@ declare module 'tls' {
|
|
|
637
637
|
* used.
|
|
638
638
|
* @since v0.5.3
|
|
639
639
|
* @param hostname A SNI host name or wildcard (e.g. `'*'`)
|
|
640
|
-
* @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc)
|
|
640
|
+
* @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc), or a TLS context object created
|
|
641
|
+
* with {@link createSecureContext} itself.
|
|
641
642
|
*/
|
|
642
643
|
addContext(hostname: string, context: SecureContextOptions): void;
|
|
643
644
|
/**
|
node/trace_events.d.ts
CHANGED
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
*
|
|
95
95
|
* The features from this module are not available in `Worker` threads.
|
|
96
96
|
* @experimental
|
|
97
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
97
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/trace_events.js)
|
|
98
98
|
*/
|
|
99
99
|
declare module 'trace_events' {
|
|
100
100
|
/**
|
node/ts4.8/assert.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `node:assert` module provides a set of assertion functions for verifying
|
|
3
3
|
* invariants.
|
|
4
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
4
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/assert.js)
|
|
5
5
|
*/
|
|
6
6
|
declare module 'assert' {
|
|
7
7
|
/**
|
|
@@ -35,9 +35,10 @@ declare module 'assert' {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* This feature is
|
|
38
|
+
* This feature is deprecated and will be removed in a future version.
|
|
39
|
+
* Please consider using alternatives such as the `mock` helper function.
|
|
39
40
|
* @since v14.2.0, v12.19.0
|
|
40
|
-
* @
|
|
41
|
+
* @deprecated Deprecated
|
|
41
42
|
*/
|
|
42
43
|
class CallTracker {
|
|
43
44
|
/**
|
|
@@ -81,7 +82,7 @@ declare module 'assert' {
|
|
|
81
82
|
* ```
|
|
82
83
|
* @since v18.8.0, v16.18.0
|
|
83
84
|
* @param fn
|
|
84
|
-
* @return An Array with the calls to a tracked function.
|
|
85
|
+
* @return An Array with all the calls to a tracked function.
|
|
85
86
|
*/
|
|
86
87
|
getCalls(fn: Function): CallTrackerCall[];
|
|
87
88
|
/**
|
node/ts4.8/async_hooks.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* import async_hooks from 'node:async_hooks';
|
|
13
13
|
* ```
|
|
14
14
|
* @experimental
|
|
15
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
15
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/async_hooks.js)
|
|
16
16
|
*/
|
|
17
17
|
declare module 'async_hooks' {
|
|
18
18
|
/**
|
|
@@ -278,9 +278,7 @@ declare module 'async_hooks' {
|
|
|
278
278
|
fn: Func,
|
|
279
279
|
type?: string,
|
|
280
280
|
thisArg?: ThisArg
|
|
281
|
-
): Func
|
|
282
|
-
asyncResource: AsyncResource;
|
|
283
|
-
};
|
|
281
|
+
): Func;
|
|
284
282
|
/**
|
|
285
283
|
* Binds the given function to execute to this `AsyncResource`'s scope.
|
|
286
284
|
* @since v14.8.0, v12.19.0
|
|
@@ -288,9 +286,7 @@ declare module 'async_hooks' {
|
|
|
288
286
|
*/
|
|
289
287
|
bind<Func extends (...args: any[]) => any>(
|
|
290
288
|
fn: Func
|
|
291
|
-
): Func
|
|
292
|
-
asyncResource: AsyncResource;
|
|
293
|
-
};
|
|
289
|
+
): Func;
|
|
294
290
|
/**
|
|
295
291
|
* Call the provided function with the provided arguments in the execution context
|
|
296
292
|
* of the async resource. This will establish the context, trigger the AsyncHooks
|
|
@@ -378,9 +374,7 @@ declare module 'async_hooks' {
|
|
|
378
374
|
*/
|
|
379
375
|
static bind<Func extends (...args: any[]) => any>(
|
|
380
376
|
fn: Func
|
|
381
|
-
): Func
|
|
382
|
-
asyncResource: AsyncResource;
|
|
383
|
-
};
|
|
377
|
+
): Func;
|
|
384
378
|
/**
|
|
385
379
|
* Captures the current execution context and returns a function that accepts a
|
|
386
380
|
* function as an argument. Whenever the returned function is called, it
|
|
@@ -410,9 +404,7 @@ declare module 'async_hooks' {
|
|
|
410
404
|
* @experimental
|
|
411
405
|
* @return A new function with the signature `(fn: (...args) : R, ...args) : R`.
|
|
412
406
|
*/
|
|
413
|
-
static snapshot():
|
|
414
|
-
asyncResource: AsyncResource;
|
|
415
|
-
};
|
|
407
|
+
static snapshot(): <R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs) => R;
|
|
416
408
|
/**
|
|
417
409
|
* Disables the instance of `AsyncLocalStorage`. All subsequent calls
|
|
418
410
|
* to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
|
node/ts4.8/buffer.d.ts
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
|
|
42
42
|
* const buf7 = Buffer.from('tést', 'latin1');
|
|
43
43
|
* ```
|
|
44
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
44
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/buffer.js)
|
|
45
45
|
*/
|
|
46
46
|
declare module 'buffer' {
|
|
47
47
|
import { BinaryLike } from 'node:crypto';
|
|
@@ -446,7 +446,7 @@ declare module 'buffer' {
|
|
|
446
446
|
*
|
|
447
447
|
* ```js
|
|
448
448
|
* const u16 = new Uint16Array([0, 0xffff]);
|
|
449
|
-
* const buf = Buffer.copyBytesFrom(u16,
|
|
449
|
+
* const buf = Buffer.copyBytesFrom(u16, 1, 1);
|
|
450
450
|
* u16[1] = 0;
|
|
451
451
|
* console.log(buf.length); // 2
|
|
452
452
|
* console.log(buf[0]); // 255
|
|
@@ -488,7 +488,7 @@ declare module 'buffer' {
|
|
|
488
488
|
* // Prints: <Buffer 00 00 00 00 00>
|
|
489
489
|
* ```
|
|
490
490
|
*
|
|
491
|
-
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `
|
|
491
|
+
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
|
492
492
|
*
|
|
493
493
|
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
|
|
494
494
|
*
|
|
@@ -525,7 +525,7 @@ declare module 'buffer' {
|
|
|
525
525
|
*/
|
|
526
526
|
alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
|
|
527
527
|
/**
|
|
528
|
-
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `
|
|
528
|
+
* 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.
|
|
529
529
|
*
|
|
530
530
|
* The underlying memory for `Buffer` instances created in this way is _not_
|
|
531
531
|
* _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.
|
|
@@ -562,8 +562,8 @@ declare module 'buffer' {
|
|
|
562
562
|
*/
|
|
563
563
|
allocUnsafe(size: number): Buffer;
|
|
564
564
|
/**
|
|
565
|
-
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `
|
|
566
|
-
*
|
|
565
|
+
* 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
|
|
566
|
+
* `size` is 0.
|
|
567
567
|
*
|
|
568
568
|
* The underlying memory for `Buffer` instances created in this way is _not_
|
|
569
569
|
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
|
node/ts4.8/child_process.d.ts
CHANGED
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
* For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however,
|
|
64
64
|
* the synchronous methods can have significant impact on performance due to
|
|
65
65
|
* stalling the event loop while spawned processes complete.
|
|
66
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
66
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/child_process.js)
|
|
67
67
|
*/
|
|
68
68
|
declare module 'child_process' {
|
|
69
69
|
import { ObjectEncodingOptions } from 'node:fs';
|
node/ts4.8/cluster.d.ts
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
* ```
|
|
51
51
|
*
|
|
52
52
|
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
|
53
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
53
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/cluster.js)
|
|
54
54
|
*/
|
|
55
55
|
declare module 'cluster' {
|
|
56
56
|
import * as child from 'node:child_process';
|
node/ts4.8/console.d.ts
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
* myConsole.warn(`Danger ${name}! Danger!`);
|
|
54
54
|
* // Prints: Danger Will Robinson! Danger!, to err
|
|
55
55
|
* ```
|
|
56
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
56
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/console.js)
|
|
57
57
|
*/
|
|
58
58
|
declare module 'console' {
|
|
59
59
|
import console = require('node:console');
|
node/ts4.8/crypto.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* // Prints:
|
|
15
15
|
* // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
|
|
16
16
|
* ```
|
|
17
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
17
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/crypto.js)
|
|
18
18
|
*/
|
|
19
19
|
declare module 'crypto' {
|
|
20
20
|
import * as stream from 'node:stream';
|
node/ts4.8/dgram.d.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* server.bind(41234);
|
|
24
24
|
* // Prints: server listening 0.0.0.0:41234
|
|
25
25
|
* ```
|
|
26
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
26
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/dgram.js)
|
|
27
27
|
*/
|
|
28
28
|
declare module 'dgram' {
|
|
29
29
|
import { AddressInfo } from 'node:net';
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* should generally include the module name to avoid collisions with data from
|
|
21
21
|
* other modules.
|
|
22
22
|
* @since v15.1.0, v14.17.0
|
|
23
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
23
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/diagnostics_channel.js)
|
|
24
24
|
*/
|
|
25
25
|
declare module 'diagnostics_channel' {
|
|
26
26
|
/**
|
node/ts4.8/dns.d.ts
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
* ```
|
|
43
43
|
*
|
|
44
44
|
* See the `Implementation considerations section` for more information.
|
|
45
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
45
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/dns.js)
|
|
46
46
|
*/
|
|
47
47
|
declare module 'dns' {
|
|
48
48
|
import * as dnsPromises from 'node:dns/promises';
|
|
@@ -484,6 +484,14 @@ declare module 'dns' {
|
|
|
484
484
|
* @since v0.1.16
|
|
485
485
|
*/
|
|
486
486
|
export function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void;
|
|
487
|
+
/**
|
|
488
|
+
* Get the default value for `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
|
|
489
|
+
*
|
|
490
|
+
* * `ipv4first`: for `verbatim` defaulting to `false`.
|
|
491
|
+
* * `verbatim`: for `verbatim` defaulting to `true`.
|
|
492
|
+
* @since v20.1.0
|
|
493
|
+
*/
|
|
494
|
+
export function getDefaultResultOrder(): 'ipv4first' | 'verbatim';
|
|
487
495
|
/**
|
|
488
496
|
* Sets the IP address and port of servers to be used when performing DNS
|
|
489
497
|
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
node/ts4.8/domain.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* will be notified, rather than losing the context of the error in the`process.on('uncaughtException')` handler, or causing the program to
|
|
13
13
|
* exit immediately with an error code.
|
|
14
14
|
* @deprecated Since v1.4.2 - Deprecated
|
|
15
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
15
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/domain.js)
|
|
16
16
|
*/
|
|
17
17
|
declare module 'domain' {
|
|
18
18
|
import EventEmitter = require('node:events');
|
|
@@ -56,7 +56,7 @@ declare module 'domain' {
|
|
|
56
56
|
exit(): void;
|
|
57
57
|
/**
|
|
58
58
|
* Run the supplied function in the context of the domain, implicitly
|
|
59
|
-
* binding all event emitters, timers, and
|
|
59
|
+
* binding all event emitters, timers, and low-level requests that are
|
|
60
60
|
* created in that context. Optionally, arguments can be passed to
|
|
61
61
|
* the function.
|
|
62
62
|
*
|
node/ts4.8/events.d.ts
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* });
|
|
33
33
|
* myEmitter.emit('event');
|
|
34
34
|
* ```
|
|
35
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
35
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/events.js)
|
|
36
36
|
*/
|
|
37
37
|
declare module 'events' {
|
|
38
38
|
// NOTE: This class is in the docs but is **not actually exported** by Node.
|
node/ts4.8/fs/promises.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ declare module 'fs/promises' {
|
|
|
14
14
|
import { ReadableStream } from 'node:stream/web';
|
|
15
15
|
import {
|
|
16
16
|
BigIntStats,
|
|
17
|
+
BigIntStatsFs,
|
|
17
18
|
BufferEncodingOption,
|
|
18
19
|
constants as fsConstants,
|
|
19
20
|
CopyOptions,
|
|
@@ -30,7 +31,9 @@ declare module 'fs/promises' {
|
|
|
30
31
|
RmDirOptions,
|
|
31
32
|
RmOptions,
|
|
32
33
|
StatOptions,
|
|
34
|
+
StatFsOptions,
|
|
33
35
|
Stats,
|
|
36
|
+
StatsFs,
|
|
34
37
|
TimeLike,
|
|
35
38
|
WatchEventType,
|
|
36
39
|
WatchOptions,
|
|
@@ -639,6 +642,7 @@ declare module 'fs/promises' {
|
|
|
639
642
|
options?:
|
|
640
643
|
| (ObjectEncodingOptions & {
|
|
641
644
|
withFileTypes?: false | undefined;
|
|
645
|
+
recursive?: boolean | undefined;
|
|
642
646
|
})
|
|
643
647
|
| BufferEncoding
|
|
644
648
|
| null
|
|
@@ -654,6 +658,7 @@ declare module 'fs/promises' {
|
|
|
654
658
|
| {
|
|
655
659
|
encoding: 'buffer';
|
|
656
660
|
withFileTypes?: false | undefined;
|
|
661
|
+
recursive?: boolean | undefined;
|
|
657
662
|
}
|
|
658
663
|
| 'buffer'
|
|
659
664
|
): Promise<Buffer[]>;
|
|
@@ -667,6 +672,7 @@ declare module 'fs/promises' {
|
|
|
667
672
|
options?:
|
|
668
673
|
| (ObjectEncodingOptions & {
|
|
669
674
|
withFileTypes?: false | undefined;
|
|
675
|
+
recursive?: boolean | undefined;
|
|
670
676
|
})
|
|
671
677
|
| BufferEncoding
|
|
672
678
|
| null
|
|
@@ -680,6 +686,7 @@ declare module 'fs/promises' {
|
|
|
680
686
|
path: PathLike,
|
|
681
687
|
options: ObjectEncodingOptions & {
|
|
682
688
|
withFileTypes: true;
|
|
689
|
+
recursive?: boolean | undefined;
|
|
683
690
|
}
|
|
684
691
|
): Promise<Dirent[]>;
|
|
685
692
|
/**
|
|
@@ -756,6 +763,23 @@ declare module 'fs/promises' {
|
|
|
756
763
|
}
|
|
757
764
|
): Promise<BigIntStats>;
|
|
758
765
|
function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
|
|
766
|
+
/**
|
|
767
|
+
* @since v19.6.0, v18.15.0
|
|
768
|
+
* @return Fulfills with the {fs.StatFs} object for the given `path`.
|
|
769
|
+
*/
|
|
770
|
+
function statfs(
|
|
771
|
+
path: PathLike,
|
|
772
|
+
opts?: StatFsOptions & {
|
|
773
|
+
bigint?: false | undefined;
|
|
774
|
+
}
|
|
775
|
+
): Promise<StatsFs>;
|
|
776
|
+
function statfs(
|
|
777
|
+
path: PathLike,
|
|
778
|
+
opts: StatFsOptions & {
|
|
779
|
+
bigint: true;
|
|
780
|
+
}
|
|
781
|
+
): Promise<BigIntStatsFs>;
|
|
782
|
+
function statfs(path: PathLike, opts?: StatFsOptions): Promise<StatsFs | BigIntStatsFs>;
|
|
759
783
|
/**
|
|
760
784
|
* Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail.
|
|
761
785
|
* @since v10.0.0
|
node/ts4.8/fs.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* All file system operations have synchronous, callback, and promise-based
|
|
18
18
|
* forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
|
|
19
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.
|
|
19
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/fs.js)
|
|
20
20
|
*/
|
|
21
21
|
declare module 'fs' {
|
|
22
22
|
import * as stream from 'node:stream';
|
|
@@ -131,6 +131,36 @@ declare module 'fs' {
|
|
|
131
131
|
* @since v0.1.21
|
|
132
132
|
*/
|
|
133
133
|
export class Stats {}
|
|
134
|
+
export interface StatsFsBase<T> {
|
|
135
|
+
/** Type of file system. */
|
|
136
|
+
type: T;
|
|
137
|
+
/** Optimal transfer block size. */
|
|
138
|
+
bsize: T;
|
|
139
|
+
/** Total data blocks in file system. */
|
|
140
|
+
blocks: T;
|
|
141
|
+
/** Free blocks in file system. */
|
|
142
|
+
bfree: T;
|
|
143
|
+
/** Available blocks for unprivileged users */
|
|
144
|
+
bavail: T;
|
|
145
|
+
/** Total file nodes in file system. */
|
|
146
|
+
files: T;
|
|
147
|
+
/** Free file nodes in file system. */
|
|
148
|
+
ffree: T;
|
|
149
|
+
}
|
|
150
|
+
export interface StatsFs extends StatsFsBase<number> {}
|
|
151
|
+
/**
|
|
152
|
+
* Provides information about a mounted file system
|
|
153
|
+
*
|
|
154
|
+
* Objects returned from {@link statfs} and {@link statfsSync} are of this type.
|
|
155
|
+
* If `bigint` in the `options` passed to those methods is true, the numeric values
|
|
156
|
+
* will be `bigint` instead of `number`.
|
|
157
|
+
* @since v18.15.0
|
|
158
|
+
*/
|
|
159
|
+
export class StatsFs {}
|
|
160
|
+
export interface BigIntStatsFs extends StatsFsBase<bigint> {}
|
|
161
|
+
export interface StatFsOptions {
|
|
162
|
+
bigint?: boolean | undefined;
|
|
163
|
+
}
|
|
134
164
|
/**
|
|
135
165
|
* A representation of a directory entry, which can be a file or a subdirectory
|
|
136
166
|
* within the directory, as returned by reading from an `fs.Dir`. The
|
|
@@ -818,6 +848,9 @@ declare module 'fs' {
|
|
|
818
848
|
*
|
|
819
849
|
* In case of an error, the `err.code` will be one of `Common System Errors`.
|
|
820
850
|
*
|
|
851
|
+
* {@link stat} follows symbolic links. Use {@link lstat} to look at the
|
|
852
|
+
* links themselves.
|
|
853
|
+
*
|
|
821
854
|
* Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended.
|
|
822
855
|
* Instead, user code should open/read/write the file directly and handle the
|
|
823
856
|
* error raised if the file is not available.
|
|
@@ -1081,6 +1114,72 @@ declare module 'fs' {
|
|
|
1081
1114
|
): Promise<BigIntStats>;
|
|
1082
1115
|
function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
|
|
1083
1116
|
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Asynchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which
|
|
1119
|
+
* contains `path`. The callback gets two arguments `(err, stats)` where `stats`is an `fs.StatFs` object.
|
|
1120
|
+
*
|
|
1121
|
+
* In case of an error, the `err.code` will be one of `Common System Errors`.
|
|
1122
|
+
* @since v19.6.0, v18.15.0
|
|
1123
|
+
* @param path A path to an existing file or directory on the file system to be queried.
|
|
1124
|
+
*/
|
|
1125
|
+
export function statfs(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void): void;
|
|
1126
|
+
export function statfs(
|
|
1127
|
+
path: PathLike,
|
|
1128
|
+
options:
|
|
1129
|
+
| (StatFsOptions & {
|
|
1130
|
+
bigint?: false | undefined;
|
|
1131
|
+
})
|
|
1132
|
+
| undefined,
|
|
1133
|
+
callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void
|
|
1134
|
+
): void;
|
|
1135
|
+
export function statfs(
|
|
1136
|
+
path: PathLike,
|
|
1137
|
+
options: StatFsOptions & {
|
|
1138
|
+
bigint: true;
|
|
1139
|
+
},
|
|
1140
|
+
callback: (err: NodeJS.ErrnoException | null, stats: BigIntStatsFs) => void
|
|
1141
|
+
): void;
|
|
1142
|
+
export function statfs(path: PathLike, options: StatFsOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs | BigIntStatsFs) => void): void;
|
|
1143
|
+
export namespace statfs {
|
|
1144
|
+
/**
|
|
1145
|
+
* Asynchronous statfs(2) - Returns information about the mounted file system which contains path. The callback gets two arguments (err, stats) where stats is an <fs.StatFs> object.
|
|
1146
|
+
* @param path A path to an existing file or directory on the file system to be queried.
|
|
1147
|
+
*/
|
|
1148
|
+
function __promisify__(
|
|
1149
|
+
path: PathLike,
|
|
1150
|
+
options?: StatFsOptions & {
|
|
1151
|
+
bigint?: false | undefined;
|
|
1152
|
+
}
|
|
1153
|
+
): Promise<StatsFs>;
|
|
1154
|
+
function __promisify__(
|
|
1155
|
+
path: PathLike,
|
|
1156
|
+
options: StatFsOptions & {
|
|
1157
|
+
bigint: true;
|
|
1158
|
+
}
|
|
1159
|
+
): Promise<BigIntStatsFs>;
|
|
1160
|
+
function __promisify__(path: PathLike, options?: StatFsOptions): Promise<StatsFs | BigIntStatsFs>;
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Synchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which
|
|
1164
|
+
* contains `path`.
|
|
1165
|
+
*
|
|
1166
|
+
* In case of an error, the `err.code` will be one of `Common System Errors`.
|
|
1167
|
+
* @since v19.6.0, v18.15.0
|
|
1168
|
+
* @param path A path to an existing file or directory on the file system to be queried.
|
|
1169
|
+
*/
|
|
1170
|
+
export function statfsSync(
|
|
1171
|
+
path: PathLike,
|
|
1172
|
+
options?: StatFsOptions & {
|
|
1173
|
+
bigint?: false | undefined;
|
|
1174
|
+
}
|
|
1175
|
+
): StatsFs;
|
|
1176
|
+
export function statfsSync(
|
|
1177
|
+
path: PathLike,
|
|
1178
|
+
options: StatFsOptions & {
|
|
1179
|
+
bigint: true;
|
|
1180
|
+
}
|
|
1181
|
+
): BigIntStatsFs;
|
|
1182
|
+
export function statfsSync(path: PathLike, options?: StatFsOptions): StatsFs | BigIntStatsFs;
|
|
1084
1183
|
/**
|
|
1085
1184
|
* Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
|
|
1086
1185
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1785,6 +1884,7 @@ declare module 'fs' {
|
|
|
1785
1884
|
| {
|
|
1786
1885
|
encoding: BufferEncoding | null;
|
|
1787
1886
|
withFileTypes?: false | undefined;
|
|
1887
|
+
recursive?: boolean | undefined;
|
|
1788
1888
|
}
|
|
1789
1889
|
| BufferEncoding
|
|
1790
1890
|
| undefined
|
|
@@ -1802,6 +1902,7 @@ declare module 'fs' {
|
|
|
1802
1902
|
| {
|
|
1803
1903
|
encoding: 'buffer';
|
|
1804
1904
|
withFileTypes?: false | undefined;
|
|
1905
|
+
recursive?: boolean | undefined;
|
|
1805
1906
|
}
|
|
1806
1907
|
| 'buffer',
|
|
1807
1908
|
callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void
|
|
@@ -1816,6 +1917,7 @@ declare module 'fs' {
|
|
|
1816
1917
|
options:
|
|
1817
1918
|
| (ObjectEncodingOptions & {
|
|
1818
1919
|
withFileTypes?: false | undefined;
|
|
1920
|
+
recursive?: boolean | undefined;
|
|
1819
1921
|
})
|
|
1820
1922
|
| BufferEncoding
|
|
1821
1923
|
| undefined
|
|
@@ -1836,6 +1938,7 @@ declare module 'fs' {
|
|
|
1836
1938
|
path: PathLike,
|
|
1837
1939
|
options: ObjectEncodingOptions & {
|
|
1838
1940
|
withFileTypes: true;
|
|
1941
|
+
recursive?: boolean | undefined;
|
|
1839
1942
|
},
|
|
1840
1943
|
callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void
|
|
1841
1944
|
): void;
|
|
@@ -1851,6 +1954,7 @@ declare module 'fs' {
|
|
|
1851
1954
|
| {
|
|
1852
1955
|
encoding: BufferEncoding | null;
|
|
1853
1956
|
withFileTypes?: false | undefined;
|
|
1957
|
+
recursive?: boolean | undefined;
|
|
1854
1958
|
}
|
|
1855
1959
|
| BufferEncoding
|
|
1856
1960
|
| null
|
|
@@ -1867,6 +1971,7 @@ declare module 'fs' {
|
|
|
1867
1971
|
| {
|
|
1868
1972
|
encoding: 'buffer';
|
|
1869
1973
|
withFileTypes?: false | undefined;
|
|
1974
|
+
recursive?: boolean | undefined;
|
|
1870
1975
|
}
|
|
1871
1976
|
): Promise<Buffer[]>;
|
|
1872
1977
|
/**
|
|
@@ -1879,6 +1984,7 @@ declare module 'fs' {
|
|
|
1879
1984
|
options?:
|
|
1880
1985
|
| (ObjectEncodingOptions & {
|
|
1881
1986
|
withFileTypes?: false | undefined;
|
|
1987
|
+
recursive?: boolean | undefined;
|
|
1882
1988
|
})
|
|
1883
1989
|
| BufferEncoding
|
|
1884
1990
|
| null
|
|
@@ -1892,6 +1998,7 @@ declare module 'fs' {
|
|
|
1892
1998
|
path: PathLike,
|
|
1893
1999
|
options: ObjectEncodingOptions & {
|
|
1894
2000
|
withFileTypes: true;
|
|
2001
|
+
recursive?: boolean | undefined;
|
|
1895
2002
|
}
|
|
1896
2003
|
): Promise<Dirent[]>;
|
|
1897
2004
|
}
|
|
@@ -1914,6 +2021,7 @@ declare module 'fs' {
|
|
|
1914
2021
|
| {
|
|
1915
2022
|
encoding: BufferEncoding | null;
|
|
1916
2023
|
withFileTypes?: false | undefined;
|
|
2024
|
+
recursive?: boolean | undefined;
|
|
1917
2025
|
}
|
|
1918
2026
|
| BufferEncoding
|
|
1919
2027
|
| null
|
|
@@ -1929,6 +2037,7 @@ declare module 'fs' {
|
|
|
1929
2037
|
| {
|
|
1930
2038
|
encoding: 'buffer';
|
|
1931
2039
|
withFileTypes?: false | undefined;
|
|
2040
|
+
recursive?: boolean | undefined;
|
|
1932
2041
|
}
|
|
1933
2042
|
| 'buffer'
|
|
1934
2043
|
): Buffer[];
|
|
@@ -1942,6 +2051,7 @@ declare module 'fs' {
|
|
|
1942
2051
|
options?:
|
|
1943
2052
|
| (ObjectEncodingOptions & {
|
|
1944
2053
|
withFileTypes?: false | undefined;
|
|
2054
|
+
recursive?: boolean | undefined;
|
|
1945
2055
|
})
|
|
1946
2056
|
| BufferEncoding
|
|
1947
2057
|
| null
|
|
@@ -1955,6 +2065,7 @@ declare module 'fs' {
|
|
|
1955
2065
|
path: PathLike,
|
|
1956
2066
|
options: ObjectEncodingOptions & {
|
|
1957
2067
|
withFileTypes: true;
|
|
2068
|
+
recursive?: boolean | undefined;
|
|
1958
2069
|
}
|
|
1959
2070
|
): Dirent[];
|
|
1960
2071
|
/**
|
|
@@ -3754,6 +3865,9 @@ declare module 'fs' {
|
|
|
3754
3865
|
*/
|
|
3755
3866
|
export function readvSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
|
|
3756
3867
|
export interface OpenDirOptions {
|
|
3868
|
+
/**
|
|
3869
|
+
* @default 'utf8'
|
|
3870
|
+
*/
|
|
3757
3871
|
encoding?: BufferEncoding | undefined;
|
|
3758
3872
|
/**
|
|
3759
3873
|
* Number of directory entries that are buffered
|
|
@@ -3762,6 +3876,10 @@ declare module 'fs' {
|
|
|
3762
3876
|
* @default 32
|
|
3763
3877
|
*/
|
|
3764
3878
|
bufferSize?: number | undefined;
|
|
3879
|
+
/**
|
|
3880
|
+
* @default false
|
|
3881
|
+
*/
|
|
3882
|
+
recursive?: boolean;
|
|
3765
3883
|
}
|
|
3766
3884
|
/**
|
|
3767
3885
|
* Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html).
|
|
@@ -3824,6 +3942,10 @@ declare module 'fs' {
|
|
|
3824
3942
|
* @default true
|
|
3825
3943
|
*/
|
|
3826
3944
|
force?: boolean;
|
|
3945
|
+
/**
|
|
3946
|
+
* Modifiers for copy operation. See `mode` flag of {@link copyFileSync()}
|
|
3947
|
+
*/
|
|
3948
|
+
mode?: number;
|
|
3827
3949
|
/**
|
|
3828
3950
|
* When `true` timestamps from `src` will
|
|
3829
3951
|
* be preserved.
|