@types/node 16.0.0 → 16.3.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 +5 -5
- node/async_hooks.d.ts +4 -6
- node/buffer.d.ts +2 -2
- node/child_process.d.ts +58 -58
- node/cluster.d.ts +10 -10
- node/console.d.ts +4 -4
- node/crypto.d.ts +69 -67
- node/dgram.d.ts +9 -9
- node/dns.d.ts +11 -11
- node/events.d.ts +3 -3
- node/fs/promises.d.ts +59 -112
- node/fs.d.ts +128 -109
- node/globals.d.ts +8 -8
- node/http.d.ts +97 -104
- node/http2.d.ts +65 -65
- node/https.d.ts +4 -4
- node/index.d.ts +1 -1
- node/inspector.d.ts +148 -148
- node/net.d.ts +30 -30
- node/os.d.ts +3 -1
- node/package.json +2 -2
- node/path.d.ts +5 -5
- node/perf_hooks.d.ts +14 -14
- node/process.d.ts +37 -38
- node/querystring.d.ts +3 -3
- node/readline.d.ts +15 -15
- node/repl.d.ts +14 -14
- node/stream.d.ts +17 -17
- node/timers.d.ts +10 -1
- node/tls.d.ts +50 -50
- node/ts3.6/base.d.ts +0 -1
- node/url.d.ts +22 -15
- node/util.d.ts +75 -13
- node/vm.d.ts +24 -24
- node/wasi.d.ts +7 -7
- node/worker_threads.d.ts +15 -15
- node/zlib.d.ts +16 -16
- node/util/types.d.ts +0 -57
node/fs/promises.d.ts
CHANGED
|
@@ -14,13 +14,40 @@ 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
22
|
} from 'fs';
|
|
23
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
|
+
}
|
|
49
|
+
|
|
50
|
+
// TODO: Add `EventEmitter` close
|
|
24
51
|
interface FileHandle {
|
|
25
52
|
/**
|
|
26
53
|
* Gets the file descriptor for this file handle.
|
|
@@ -37,7 +64,7 @@ declare module 'fs/promises' {
|
|
|
37
64
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
38
65
|
* If `flag` is not supplied, the default of `'a'` is used.
|
|
39
66
|
*/
|
|
40
|
-
appendFile(data: string | Uint8Array, options?:
|
|
67
|
+
appendFile(data: string | Uint8Array, options?: ObjectEncodingOptions & FlagAndOpenMode | BufferEncoding | null): Promise<void>;
|
|
41
68
|
|
|
42
69
|
/**
|
|
43
70
|
* Asynchronous fchown(2) - Change ownership of a file.
|
|
@@ -68,15 +95,15 @@ declare module 'fs/promises' {
|
|
|
68
95
|
* @param length The number of bytes to read.
|
|
69
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.
|
|
70
97
|
*/
|
|
71
|
-
read<
|
|
72
|
-
|
|
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>>;
|
|
73
100
|
/**
|
|
74
101
|
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
|
75
102
|
* The `FileHandle` must have been opened for reading.
|
|
76
103
|
* @param options An object that may contain an optional flag.
|
|
77
104
|
* If a flag is not provided, it defaults to `'r'`.
|
|
78
105
|
*/
|
|
79
|
-
readFile(options?: { encoding?: null, flag?: OpenMode } | null): Promise<Buffer>;
|
|
106
|
+
readFile(options?: { encoding?: null | undefined, flag?: OpenMode | undefined } | null): Promise<Buffer>;
|
|
80
107
|
|
|
81
108
|
/**
|
|
82
109
|
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
|
@@ -84,7 +111,7 @@ declare module 'fs/promises' {
|
|
|
84
111
|
* @param options An object that may contain an optional flag.
|
|
85
112
|
* If a flag is not provided, it defaults to `'r'`.
|
|
86
113
|
*/
|
|
87
|
-
readFile(options: { encoding: BufferEncoding, flag?: OpenMode } | BufferEncoding): Promise<string>;
|
|
114
|
+
readFile(options: { encoding: BufferEncoding, flag?: OpenMode | undefined } | BufferEncoding): Promise<string>;
|
|
88
115
|
|
|
89
116
|
/**
|
|
90
117
|
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
|
@@ -92,12 +119,12 @@ declare module 'fs/promises' {
|
|
|
92
119
|
* @param options An object that may contain an optional flag.
|
|
93
120
|
* If a flag is not provided, it defaults to `'r'`.
|
|
94
121
|
*/
|
|
95
|
-
readFile(options?:
|
|
122
|
+
readFile(options?: ObjectEncodingOptions & { flag?: OpenMode | undefined } | BufferEncoding | null): Promise<string | Buffer>;
|
|
96
123
|
|
|
97
124
|
/**
|
|
98
125
|
* Asynchronous fstat(2) - Get file status.
|
|
99
126
|
*/
|
|
100
|
-
stat(opts?: StatOptions & { bigint?: false }): Promise<Stats>;
|
|
127
|
+
stat(opts?: StatOptions & { bigint?: false | undefined }): Promise<Stats>;
|
|
101
128
|
stat(opts: StatOptions & { bigint: true }): Promise<BigIntStats>;
|
|
102
129
|
stat(opts?: StatOptions): Promise<Stats | BigIntStats>;
|
|
103
130
|
|
|
@@ -146,7 +173,7 @@ declare module 'fs/promises' {
|
|
|
146
173
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
147
174
|
* If `flag` is not supplied, the default of `'w'` is used.
|
|
148
175
|
*/
|
|
149
|
-
writeFile(data: string | Uint8Array, options?:
|
|
176
|
+
writeFile(data: string | Uint8Array, options?: ObjectEncodingOptions & FlagAndOpenMode & Abortable | BufferEncoding | null): Promise<void>;
|
|
150
177
|
|
|
151
178
|
/**
|
|
152
179
|
* See `fs.writev` promisified version.
|
|
@@ -192,50 +219,6 @@ declare module 'fs/promises' {
|
|
|
192
219
|
*/
|
|
193
220
|
function open(path: PathLike, flags: string | number, mode?: Mode): Promise<FileHandle>;
|
|
194
221
|
|
|
195
|
-
/**
|
|
196
|
-
* Asynchronously reads data from the file referenced by the supplied `FileHandle`.
|
|
197
|
-
* @param handle A `FileHandle`.
|
|
198
|
-
* @param buffer The buffer that the data will be written to.
|
|
199
|
-
* @param offset The offset in the buffer at which to start writing.
|
|
200
|
-
* @param length The number of bytes to read.
|
|
201
|
-
* @param position The offset from the beginning of the file from which data should be read. If
|
|
202
|
-
* `null`, data will be read from the current position.
|
|
203
|
-
*/
|
|
204
|
-
function read<TBuffer extends Uint8Array>(
|
|
205
|
-
handle: FileHandle,
|
|
206
|
-
buffer: TBuffer,
|
|
207
|
-
offset?: number | null,
|
|
208
|
-
length?: number | null,
|
|
209
|
-
position?: number | null,
|
|
210
|
-
): Promise<{ bytesRead: number, buffer: TBuffer }>;
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Asynchronously writes `buffer` to the file referenced by the supplied `FileHandle`.
|
|
214
|
-
* It is unsafe to call `fsPromises.write()` multiple times on the same file without waiting for the `Promise`
|
|
215
|
-
* to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
|
|
216
|
-
* @param handle A `FileHandle`.
|
|
217
|
-
* @param buffer The buffer that the data will be written to.
|
|
218
|
-
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
|
|
219
|
-
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
|
|
220
|
-
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
|
221
|
-
*/
|
|
222
|
-
function write<TBuffer extends Uint8Array>(
|
|
223
|
-
handle: FileHandle,
|
|
224
|
-
buffer: TBuffer,
|
|
225
|
-
offset?: number | null,
|
|
226
|
-
length?: number | null, position?: number | null): Promise<{ bytesWritten: number, buffer: TBuffer }>;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Asynchronously writes `string` to the file referenced by the supplied `FileHandle`.
|
|
230
|
-
* It is unsafe to call `fsPromises.write()` multiple times on the same file without waiting for the `Promise`
|
|
231
|
-
* to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
|
|
232
|
-
* @param handle A `FileHandle`.
|
|
233
|
-
* @param string A string to write.
|
|
234
|
-
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
|
235
|
-
* @param encoding The expected string encoding.
|
|
236
|
-
*/
|
|
237
|
-
function write(handle: FileHandle, string: string, position?: number | null, encoding?: BufferEncoding | null): Promise<{ bytesWritten: number, buffer: string }>;
|
|
238
|
-
|
|
239
222
|
/**
|
|
240
223
|
* Asynchronous rename(2) - Change the name or location of a file or directory.
|
|
241
224
|
* @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -252,13 +235,6 @@ declare module 'fs/promises' {
|
|
|
252
235
|
*/
|
|
253
236
|
function truncate(path: PathLike, len?: number): Promise<void>;
|
|
254
237
|
|
|
255
|
-
/**
|
|
256
|
-
* Asynchronous ftruncate(2) - Truncate a file to a specified length.
|
|
257
|
-
* @param handle A `FileHandle`.
|
|
258
|
-
* @param len If not specified, defaults to `0`.
|
|
259
|
-
*/
|
|
260
|
-
function ftruncate(handle: FileHandle, len?: number): Promise<void>;
|
|
261
|
-
|
|
262
238
|
/**
|
|
263
239
|
* Asynchronous rmdir(2) - delete a directory.
|
|
264
240
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -270,18 +246,6 @@ declare module 'fs/promises' {
|
|
|
270
246
|
*/
|
|
271
247
|
function rm(path: PathLike, options?: RmOptions): Promise<void>;
|
|
272
248
|
|
|
273
|
-
/**
|
|
274
|
-
* Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
|
|
275
|
-
* @param handle A `FileHandle`.
|
|
276
|
-
*/
|
|
277
|
-
function fdatasync(handle: FileHandle): Promise<void>;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
|
|
281
|
-
* @param handle A `FileHandle`.
|
|
282
|
-
*/
|
|
283
|
-
function fsync(handle: FileHandle): Promise<void>;
|
|
284
|
-
|
|
285
249
|
/**
|
|
286
250
|
* Asynchronous mkdir(2) - create a directory.
|
|
287
251
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -296,7 +260,7 @@ declare module 'fs/promises' {
|
|
|
296
260
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
|
297
261
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
|
298
262
|
*/
|
|
299
|
-
function mkdir(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null): Promise<void>;
|
|
263
|
+
function mkdir(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false | undefined; }) | null): Promise<void>;
|
|
300
264
|
|
|
301
265
|
/**
|
|
302
266
|
* Asynchronous mkdir(2) - create a directory.
|
|
@@ -311,35 +275,35 @@ declare module 'fs/promises' {
|
|
|
311
275
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
312
276
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
313
277
|
*/
|
|
314
|
-
function readdir(path: PathLike, options?:
|
|
278
|
+
function readdir(path: PathLike, options?: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[]>;
|
|
315
279
|
|
|
316
280
|
/**
|
|
317
281
|
* Asynchronous readdir(3) - read a directory.
|
|
318
282
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
319
283
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
320
284
|
*/
|
|
321
|
-
function readdir(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer"): Promise<Buffer[]>;
|
|
285
|
+
function readdir(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false | undefined } | "buffer"): Promise<Buffer[]>;
|
|
322
286
|
|
|
323
287
|
/**
|
|
324
288
|
* Asynchronous readdir(3) - read a directory.
|
|
325
289
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
326
290
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
327
291
|
*/
|
|
328
|
-
function readdir(path: PathLike, options?:
|
|
292
|
+
function readdir(path: PathLike, options?: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[] | Buffer[]>;
|
|
329
293
|
|
|
330
294
|
/**
|
|
331
295
|
* Asynchronous readdir(3) - read a directory.
|
|
332
296
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
333
297
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
|
|
334
298
|
*/
|
|
335
|
-
function readdir(path: PathLike, options:
|
|
299
|
+
function readdir(path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true }): Promise<Dirent[]>;
|
|
336
300
|
|
|
337
301
|
/**
|
|
338
302
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
339
303
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
340
304
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
341
305
|
*/
|
|
342
|
-
function readlink(path: PathLike, options?:
|
|
306
|
+
function readlink(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
|
343
307
|
|
|
344
308
|
/**
|
|
345
309
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
@@ -353,7 +317,7 @@ declare module 'fs/promises' {
|
|
|
353
317
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
354
318
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
355
319
|
*/
|
|
356
|
-
function readlink(path: PathLike, options?:
|
|
320
|
+
function readlink(path: PathLike, options?: ObjectEncodingOptions | string | null): Promise<string | Buffer>;
|
|
357
321
|
|
|
358
322
|
/**
|
|
359
323
|
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
|
|
@@ -368,7 +332,7 @@ declare module 'fs/promises' {
|
|
|
368
332
|
* Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
|
|
369
333
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
370
334
|
*/
|
|
371
|
-
function lstat(path: PathLike, opts?: StatOptions & { bigint?: false }): Promise<Stats>;
|
|
335
|
+
function lstat(path: PathLike, opts?: StatOptions & { bigint?: false | undefined }): Promise<Stats>;
|
|
372
336
|
function lstat(path: PathLike, opts: StatOptions & { bigint: true }): Promise<BigIntStats>;
|
|
373
337
|
function lstat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
|
|
374
338
|
|
|
@@ -376,7 +340,7 @@ declare module 'fs/promises' {
|
|
|
376
340
|
* Asynchronous stat(2) - Get file status.
|
|
377
341
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
378
342
|
*/
|
|
379
|
-
function stat(path: PathLike, opts?: StatOptions & { bigint?: false }): Promise<Stats>;
|
|
343
|
+
function stat(path: PathLike, opts?: StatOptions & { bigint?: false | undefined }): Promise<Stats>;
|
|
380
344
|
function stat(path: PathLike, opts: StatOptions & { bigint: true }): Promise<BigIntStats>;
|
|
381
345
|
function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
|
|
382
346
|
|
|
@@ -393,13 +357,6 @@ declare module 'fs/promises' {
|
|
|
393
357
|
*/
|
|
394
358
|
function unlink(path: PathLike): Promise<void>;
|
|
395
359
|
|
|
396
|
-
/**
|
|
397
|
-
* Asynchronous fchmod(2) - Change permissions of a file.
|
|
398
|
-
* @param handle A `FileHandle`.
|
|
399
|
-
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
|
400
|
-
*/
|
|
401
|
-
function fchmod(handle: FileHandle, mode: Mode): Promise<void>;
|
|
402
|
-
|
|
403
360
|
/**
|
|
404
361
|
* Asynchronous chmod(2) - Change permissions of a file.
|
|
405
362
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -430,12 +387,6 @@ declare module 'fs/promises' {
|
|
|
430
387
|
*/
|
|
431
388
|
function lutimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
|
432
389
|
|
|
433
|
-
/**
|
|
434
|
-
* Asynchronous fchown(2) - Change ownership of a file.
|
|
435
|
-
* @param handle A `FileHandle`.
|
|
436
|
-
*/
|
|
437
|
-
function fchown(handle: FileHandle, uid: number, gid: number): Promise<void>;
|
|
438
|
-
|
|
439
390
|
/**
|
|
440
391
|
* Asynchronous chown(2) - Change ownership of a file.
|
|
441
392
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -450,20 +401,12 @@ declare module 'fs/promises' {
|
|
|
450
401
|
*/
|
|
451
402
|
function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
|
452
403
|
|
|
453
|
-
/**
|
|
454
|
-
* Asynchronously change file timestamps of the file referenced by the supplied `FileHandle`.
|
|
455
|
-
* @param handle A `FileHandle`.
|
|
456
|
-
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
457
|
-
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
458
|
-
*/
|
|
459
|
-
function futimes(handle: FileHandle, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
|
460
|
-
|
|
461
404
|
/**
|
|
462
405
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
463
406
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
464
407
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
465
408
|
*/
|
|
466
|
-
function realpath(path: PathLike, options?:
|
|
409
|
+
function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
|
467
410
|
|
|
468
411
|
/**
|
|
469
412
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
@@ -477,14 +420,14 @@ declare module 'fs/promises' {
|
|
|
477
420
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
478
421
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
479
422
|
*/
|
|
480
|
-
function realpath(path: PathLike, options?:
|
|
423
|
+
function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
|
481
424
|
|
|
482
425
|
/**
|
|
483
426
|
* Asynchronously creates a unique temporary directory.
|
|
484
427
|
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
|
485
428
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
486
429
|
*/
|
|
487
|
-
function mkdtemp(prefix: string, options?:
|
|
430
|
+
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
|
488
431
|
|
|
489
432
|
/**
|
|
490
433
|
* Asynchronously creates a unique temporary directory.
|
|
@@ -498,7 +441,7 @@ declare module 'fs/promises' {
|
|
|
498
441
|
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
|
499
442
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
500
443
|
*/
|
|
501
|
-
function mkdtemp(prefix: string, options?:
|
|
444
|
+
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
|
502
445
|
|
|
503
446
|
/**
|
|
504
447
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
|
@@ -516,8 +459,8 @@ declare module 'fs/promises' {
|
|
|
516
459
|
function writeFile(
|
|
517
460
|
path: PathLike | FileHandle,
|
|
518
461
|
data: string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | Stream,
|
|
519
|
-
options?:
|
|
520
|
-
|
|
462
|
+
options?: ObjectEncodingOptions & { mode?: Mode | undefined, flag?: OpenMode | undefined } & Abortable | BufferEncoding | null
|
|
463
|
+
): Promise<void>;
|
|
521
464
|
|
|
522
465
|
/**
|
|
523
466
|
* Asynchronously append data to a file, creating the file if it does not exist.
|
|
@@ -531,7 +474,11 @@ declare module 'fs/promises' {
|
|
|
531
474
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
532
475
|
* If `flag` is not supplied, the default of `'a'` is used.
|
|
533
476
|
*/
|
|
534
|
-
function appendFile(
|
|
477
|
+
function appendFile(
|
|
478
|
+
path: PathLike | FileHandle,
|
|
479
|
+
data: string | Uint8Array,
|
|
480
|
+
options?: ObjectEncodingOptions & FlagAndOpenMode | BufferEncoding | null,
|
|
481
|
+
): Promise<void>;
|
|
535
482
|
|
|
536
483
|
/**
|
|
537
484
|
* Asynchronously reads the entire contents of a file.
|
|
@@ -540,7 +487,7 @@ declare module 'fs/promises' {
|
|
|
540
487
|
* @param options An object that may contain an optional flag.
|
|
541
488
|
* If a flag is not provided, it defaults to `'r'`.
|
|
542
489
|
*/
|
|
543
|
-
function readFile(path: PathLike | FileHandle, options?: { encoding?: null, flag?: OpenMode } & Abortable | null): Promise<Buffer>;
|
|
490
|
+
function readFile(path: PathLike | FileHandle, options?: { encoding?: null | undefined, flag?: OpenMode | undefined } & Abortable | null): Promise<Buffer>;
|
|
544
491
|
|
|
545
492
|
/**
|
|
546
493
|
* Asynchronously reads the entire contents of a file.
|
|
@@ -549,7 +496,7 @@ declare module 'fs/promises' {
|
|
|
549
496
|
* @param options An object that may contain an optional flag.
|
|
550
497
|
* If a flag is not provided, it defaults to `'r'`.
|
|
551
498
|
*/
|
|
552
|
-
function readFile(path: PathLike | FileHandle, options: { encoding: BufferEncoding, flag?: OpenMode } & Abortable | BufferEncoding): Promise<string>;
|
|
499
|
+
function readFile(path: PathLike | FileHandle, options: { encoding: BufferEncoding, flag?: OpenMode | undefined } & Abortable | BufferEncoding): Promise<string>;
|
|
553
500
|
|
|
554
501
|
/**
|
|
555
502
|
* Asynchronously reads the entire contents of a file.
|
|
@@ -558,7 +505,7 @@ declare module 'fs/promises' {
|
|
|
558
505
|
* @param options An object that may contain an optional flag.
|
|
559
506
|
* If a flag is not provided, it defaults to `'r'`.
|
|
560
507
|
*/
|
|
561
|
-
function readFile(path: PathLike | FileHandle, options?:
|
|
508
|
+
function readFile(path: PathLike | FileHandle, options?: ObjectEncodingOptions & Abortable & { flag?: OpenMode | undefined } | BufferEncoding | null): Promise<string | Buffer>;
|
|
562
509
|
|
|
563
510
|
function opendir(path: string, options?: OpenDirOptions): Promise<Dir>;
|
|
564
511
|
|