@types/node 16.0.3 → 16.3.3
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/strict.d.ts +3 -3
- node/async_hooks.d.ts +2 -4
- node/buffer.d.ts +25 -22
- node/child_process.d.ts +13 -13
- node/cluster.d.ts +4 -3
- node/console.d.ts +6 -6
- node/constants.d.ts +3 -3
- node/crypto.d.ts +6 -4
- node/dgram.d.ts +3 -3
- node/{diagnostic_channel.d.ts → diagnostics_channel.d.ts} +3 -3
- node/dns/promises.d.ts +1 -1
- node/dns.d.ts +1 -1
- node/domain.d.ts +7 -7
- node/events.d.ts +1 -1
- node/fs/promises.d.ts +47 -21
- node/fs.d.ts +69 -64
- node/http.d.ts +3 -3
- node/http2.d.ts +8 -8
- node/https.d.ts +3 -3
- node/index.d.ts +1 -1
- node/inspector.d.ts +325 -2
- node/module.d.ts +1 -1
- node/net.d.ts +3 -3
- node/os.d.ts +3 -1
- node/package.json +2 -2
- node/perf_hooks.d.ts +1 -1
- node/process.d.ts +25 -26
- node/readline.d.ts +1 -1
- node/repl.d.ts +3 -3
- node/stream/promises.d.ts +1 -1
- node/stream.d.ts +2 -2
- node/timers/promises.d.ts +1 -1
- node/timers.d.ts +2 -28
- node/tls.d.ts +2 -2
- node/ts3.6/assert.d.ts +5 -0
- node/ts3.6/base.d.ts +1 -2
- node/tty.d.ts +1 -1
- node/url.d.ts +2 -2
- node/util.d.ts +67 -1
- node/v8.d.ts +1 -1
- node/worker_threads.d.ts +7 -7
- node/zlib.d.ts +1 -1
- node/util/types.d.ts +0 -57
node/fs/promises.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare module 'fs/promises' {
|
|
2
|
-
import { Abortable } from 'events';
|
|
3
|
-
import { Stream } from 'stream';
|
|
2
|
+
import { Abortable } from 'node:events';
|
|
3
|
+
import { Stream } from 'node:stream';
|
|
4
4
|
import {
|
|
5
5
|
Stats,
|
|
6
6
|
BigIntStats,
|
|
@@ -14,12 +14,38 @@ declare module 'fs/promises' {
|
|
|
14
14
|
Dirent,
|
|
15
15
|
OpenDirOptions,
|
|
16
16
|
Dir,
|
|
17
|
-
|
|
17
|
+
ObjectEncodingOptions,
|
|
18
18
|
BufferEncodingOption,
|
|
19
19
|
OpenMode,
|
|
20
20
|
Mode,
|
|
21
21
|
WatchOptions,
|
|
22
|
-
} from 'fs';
|
|
22
|
+
} from 'node:fs';
|
|
23
|
+
|
|
24
|
+
interface FlagAndOpenMode {
|
|
25
|
+
mode?: Mode | undefined;
|
|
26
|
+
flag?: OpenMode | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface FileReadResult<T extends ArrayBufferView> {
|
|
30
|
+
bytesRead: number;
|
|
31
|
+
buffer: T;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface FileReadOptions<T extends ArrayBufferView = Buffer> {
|
|
35
|
+
/**
|
|
36
|
+
* @default `Buffer.alloc(0xffff)`
|
|
37
|
+
*/
|
|
38
|
+
buffer?: T;
|
|
39
|
+
/**
|
|
40
|
+
* @default 0
|
|
41
|
+
*/
|
|
42
|
+
offset?: number | null;
|
|
43
|
+
/**
|
|
44
|
+
* @default `buffer.byteLength`
|
|
45
|
+
*/
|
|
46
|
+
length?: number | null;
|
|
47
|
+
position?: number | null;
|
|
48
|
+
}
|
|
23
49
|
|
|
24
50
|
// TODO: Add `EventEmitter` close
|
|
25
51
|
interface FileHandle {
|
|
@@ -38,7 +64,7 @@ declare module 'fs/promises' {
|
|
|
38
64
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
39
65
|
* If `flag` is not supplied, the default of `'a'` is used.
|
|
40
66
|
*/
|
|
41
|
-
appendFile(data: string | Uint8Array, options?:
|
|
67
|
+
appendFile(data: string | Uint8Array, options?: ObjectEncodingOptions & FlagAndOpenMode | BufferEncoding | null): Promise<void>;
|
|
42
68
|
|
|
43
69
|
/**
|
|
44
70
|
* Asynchronous fchown(2) - Change ownership of a file.
|
|
@@ -69,8 +95,8 @@ declare module 'fs/promises' {
|
|
|
69
95
|
* @param length The number of bytes to read.
|
|
70
96
|
* @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
|
|
71
97
|
*/
|
|
72
|
-
read<
|
|
73
|
-
|
|
98
|
+
read<T extends ArrayBufferView>(buffer: T, offset?: number | null, length?: number | null, position?: number | null): Promise<FileReadResult<T>>;
|
|
99
|
+
read<T extends ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
|
|
74
100
|
/**
|
|
75
101
|
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
|
76
102
|
* The `FileHandle` must have been opened for reading.
|
|
@@ -93,7 +119,7 @@ declare module 'fs/promises' {
|
|
|
93
119
|
* @param options An object that may contain an optional flag.
|
|
94
120
|
* If a flag is not provided, it defaults to `'r'`.
|
|
95
121
|
*/
|
|
96
|
-
readFile(options?:
|
|
122
|
+
readFile(options?: ObjectEncodingOptions & { flag?: OpenMode | undefined } | BufferEncoding | null): Promise<string | Buffer>;
|
|
97
123
|
|
|
98
124
|
/**
|
|
99
125
|
* Asynchronous fstat(2) - Get file status.
|
|
@@ -147,7 +173,7 @@ declare module 'fs/promises' {
|
|
|
147
173
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
148
174
|
* If `flag` is not supplied, the default of `'w'` is used.
|
|
149
175
|
*/
|
|
150
|
-
writeFile(data: string | Uint8Array, options?:
|
|
176
|
+
writeFile(data: string | Uint8Array, options?: ObjectEncodingOptions & FlagAndOpenMode & Abortable | BufferEncoding | null): Promise<void>;
|
|
151
177
|
|
|
152
178
|
/**
|
|
153
179
|
* See `fs.writev` promisified version.
|
|
@@ -249,7 +275,7 @@ declare module 'fs/promises' {
|
|
|
249
275
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
250
276
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
251
277
|
*/
|
|
252
|
-
function readdir(path: PathLike, options?:
|
|
278
|
+
function readdir(path: PathLike, options?: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[]>;
|
|
253
279
|
|
|
254
280
|
/**
|
|
255
281
|
* Asynchronous readdir(3) - read a directory.
|
|
@@ -263,21 +289,21 @@ declare module 'fs/promises' {
|
|
|
263
289
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
264
290
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
265
291
|
*/
|
|
266
|
-
function readdir(path: PathLike, options?:
|
|
292
|
+
function readdir(path: PathLike, options?: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[] | Buffer[]>;
|
|
267
293
|
|
|
268
294
|
/**
|
|
269
295
|
* Asynchronous readdir(3) - read a directory.
|
|
270
296
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
271
297
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
|
|
272
298
|
*/
|
|
273
|
-
function readdir(path: PathLike, options:
|
|
299
|
+
function readdir(path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true }): Promise<Dirent[]>;
|
|
274
300
|
|
|
275
301
|
/**
|
|
276
302
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
277
303
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
278
304
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
279
305
|
*/
|
|
280
|
-
function readlink(path: PathLike, options?:
|
|
306
|
+
function readlink(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
|
281
307
|
|
|
282
308
|
/**
|
|
283
309
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
@@ -291,7 +317,7 @@ declare module 'fs/promises' {
|
|
|
291
317
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
292
318
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
293
319
|
*/
|
|
294
|
-
function readlink(path: PathLike, options?:
|
|
320
|
+
function readlink(path: PathLike, options?: ObjectEncodingOptions | string | null): Promise<string | Buffer>;
|
|
295
321
|
|
|
296
322
|
/**
|
|
297
323
|
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
|
|
@@ -380,7 +406,7 @@ declare module 'fs/promises' {
|
|
|
380
406
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
381
407
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
382
408
|
*/
|
|
383
|
-
function realpath(path: PathLike, options?:
|
|
409
|
+
function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
|
384
410
|
|
|
385
411
|
/**
|
|
386
412
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
@@ -394,14 +420,14 @@ declare module 'fs/promises' {
|
|
|
394
420
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
395
421
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
396
422
|
*/
|
|
397
|
-
function realpath(path: PathLike, options?:
|
|
423
|
+
function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
|
398
424
|
|
|
399
425
|
/**
|
|
400
426
|
* Asynchronously creates a unique temporary directory.
|
|
401
427
|
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
|
402
428
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
403
429
|
*/
|
|
404
|
-
function mkdtemp(prefix: string, options?:
|
|
430
|
+
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
|
405
431
|
|
|
406
432
|
/**
|
|
407
433
|
* Asynchronously creates a unique temporary directory.
|
|
@@ -415,7 +441,7 @@ declare module 'fs/promises' {
|
|
|
415
441
|
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
|
416
442
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
417
443
|
*/
|
|
418
|
-
function mkdtemp(prefix: string, options?:
|
|
444
|
+
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
|
419
445
|
|
|
420
446
|
/**
|
|
421
447
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
|
@@ -433,7 +459,7 @@ declare module 'fs/promises' {
|
|
|
433
459
|
function writeFile(
|
|
434
460
|
path: PathLike | FileHandle,
|
|
435
461
|
data: string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | Stream,
|
|
436
|
-
options?:
|
|
462
|
+
options?: ObjectEncodingOptions & { mode?: Mode | undefined, flag?: OpenMode | undefined } & Abortable | BufferEncoding | null
|
|
437
463
|
): Promise<void>;
|
|
438
464
|
|
|
439
465
|
/**
|
|
@@ -451,7 +477,7 @@ declare module 'fs/promises' {
|
|
|
451
477
|
function appendFile(
|
|
452
478
|
path: PathLike | FileHandle,
|
|
453
479
|
data: string | Uint8Array,
|
|
454
|
-
options?:
|
|
480
|
+
options?: ObjectEncodingOptions & FlagAndOpenMode | BufferEncoding | null,
|
|
455
481
|
): Promise<void>;
|
|
456
482
|
|
|
457
483
|
/**
|
|
@@ -479,7 +505,7 @@ declare module 'fs/promises' {
|
|
|
479
505
|
* @param options An object that may contain an optional flag.
|
|
480
506
|
* If a flag is not provided, it defaults to `'r'`.
|
|
481
507
|
*/
|
|
482
|
-
function readFile(path: PathLike | FileHandle, options?:
|
|
508
|
+
function readFile(path: PathLike | FileHandle, options?: ObjectEncodingOptions & Abortable & { flag?: OpenMode | undefined } | BufferEncoding | null): Promise<string | Buffer>;
|
|
483
509
|
|
|
484
510
|
function opendir(path: string, options?: OpenDirOptions): Promise<Dir>;
|
|
485
511
|
|