@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.d.ts
CHANGED
|
@@ -10,14 +10,20 @@ declare module 'fs' {
|
|
|
10
10
|
*/
|
|
11
11
|
export type PathLike = string | Buffer | URL;
|
|
12
12
|
|
|
13
|
+
export type PathOrFileDescriptor = PathLike | number;
|
|
14
|
+
|
|
15
|
+
export type TimeLike = string | number | Date;
|
|
16
|
+
|
|
13
17
|
export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
|
|
14
18
|
|
|
15
19
|
export type BufferEncodingOption = 'buffer' | { encoding: 'buffer' };
|
|
16
20
|
|
|
17
|
-
export interface
|
|
18
|
-
encoding?: BufferEncoding | null;
|
|
21
|
+
export interface ObjectEncodingOptions {
|
|
22
|
+
encoding?: BufferEncoding | null | undefined;
|
|
19
23
|
}
|
|
20
24
|
|
|
25
|
+
export type EncodingOption = ObjectEncodingOptions | BufferEncoding | undefined | null;
|
|
26
|
+
|
|
21
27
|
export type OpenMode = number | string;
|
|
22
28
|
|
|
23
29
|
export type Mode = number | string;
|
|
@@ -71,7 +77,7 @@ declare module 'fs' {
|
|
|
71
77
|
/**
|
|
72
78
|
* A class representing a directory stream.
|
|
73
79
|
*/
|
|
74
|
-
export class Dir {
|
|
80
|
+
export class Dir implements AsyncIterable<Dirent> {
|
|
75
81
|
readonly path: string;
|
|
76
82
|
|
|
77
83
|
/**
|
|
@@ -430,7 +436,7 @@ declare module 'fs' {
|
|
|
430
436
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
431
437
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
432
438
|
*/
|
|
433
|
-
export function lutimes(path: PathLike, atime:
|
|
439
|
+
export function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
|
|
434
440
|
|
|
435
441
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
436
442
|
export namespace lutimes {
|
|
@@ -442,7 +448,7 @@ declare module 'fs' {
|
|
|
442
448
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
443
449
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
444
450
|
*/
|
|
445
|
-
function __promisify__(path: PathLike, atime:
|
|
451
|
+
function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
|
|
446
452
|
}
|
|
447
453
|
|
|
448
454
|
/**
|
|
@@ -453,7 +459,7 @@ declare module 'fs' {
|
|
|
453
459
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
454
460
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
455
461
|
*/
|
|
456
|
-
export function lutimesSync(path: PathLike, atime:
|
|
462
|
+
export function lutimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
|
|
457
463
|
|
|
458
464
|
/**
|
|
459
465
|
* Asynchronous chmod(2) - Change permissions of a file.
|
|
@@ -532,7 +538,7 @@ declare module 'fs' {
|
|
|
532
538
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
533
539
|
*/
|
|
534
540
|
export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
535
|
-
export function stat(path: PathLike, options: StatOptions & { bigint?: false } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
541
|
+
export function stat(path: PathLike, options: StatOptions & { bigint?: false | undefined } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
536
542
|
export function stat(path: PathLike, options: StatOptions & { bigint: true }, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void;
|
|
537
543
|
export function stat(path: PathLike, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
|
|
538
544
|
|
|
@@ -542,18 +548,18 @@ declare module 'fs' {
|
|
|
542
548
|
* Asynchronous stat(2) - Get file status.
|
|
543
549
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
544
550
|
*/
|
|
545
|
-
function __promisify__(path: PathLike, options?: StatOptions & { bigint?: false }): Promise<Stats>;
|
|
551
|
+
function __promisify__(path: PathLike, options?: StatOptions & { bigint?: false | undefined }): Promise<Stats>;
|
|
546
552
|
function __promisify__(path: PathLike, options: StatOptions & { bigint: true }): Promise<BigIntStats>;
|
|
547
553
|
function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
|
|
548
554
|
}
|
|
549
555
|
|
|
550
556
|
export interface StatSyncFn<TDescriptor = PathLike> extends Function {
|
|
551
557
|
(path: TDescriptor, options?: undefined): Stats;
|
|
552
|
-
(path: TDescriptor, options?: StatOptions & { bigint?: false; throwIfNoEntry: false }): Stats | undefined;
|
|
558
|
+
(path: TDescriptor, options?: StatOptions & { bigint?: false | undefined; throwIfNoEntry: false }): Stats | undefined;
|
|
553
559
|
(path: TDescriptor, options: StatOptions & { bigint: true; throwIfNoEntry: false }): BigIntStats | undefined;
|
|
554
|
-
(path: TDescriptor, options?: StatOptions & { bigint?: false }): Stats;
|
|
560
|
+
(path: TDescriptor, options?: StatOptions & { bigint?: false | undefined }): Stats;
|
|
555
561
|
(path: TDescriptor, options: StatOptions & { bigint: true }): BigIntStats;
|
|
556
|
-
(path: TDescriptor, options: StatOptions & { bigint: boolean; throwIfNoEntry?: false }): Stats | BigIntStats;
|
|
562
|
+
(path: TDescriptor, options: StatOptions & { bigint: boolean; throwIfNoEntry?: false | undefined }): Stats | BigIntStats;
|
|
557
563
|
(path: TDescriptor, options?: StatOptions): Stats | BigIntStats | undefined;
|
|
558
564
|
}
|
|
559
565
|
|
|
@@ -568,7 +574,7 @@ declare module 'fs' {
|
|
|
568
574
|
* @param fd A file descriptor.
|
|
569
575
|
*/
|
|
570
576
|
export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
571
|
-
export function fstat(fd: number, options: StatOptions & { bigint?: false } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
577
|
+
export function fstat(fd: number, options: StatOptions & { bigint?: false | undefined } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
572
578
|
export function fstat(fd: number, options: StatOptions & { bigint: true }, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void;
|
|
573
579
|
export function fstat(fd: number, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
|
|
574
580
|
|
|
@@ -578,7 +584,7 @@ declare module 'fs' {
|
|
|
578
584
|
* Asynchronous fstat(2) - Get file status.
|
|
579
585
|
* @param fd A file descriptor.
|
|
580
586
|
*/
|
|
581
|
-
function __promisify__(fd: number, options?: StatOptions & { bigint?: false }): Promise<Stats>;
|
|
587
|
+
function __promisify__(fd: number, options?: StatOptions & { bigint?: false | undefined }): Promise<Stats>;
|
|
582
588
|
function __promisify__(fd: number, options: StatOptions & { bigint: true }): Promise<BigIntStats>;
|
|
583
589
|
function __promisify__(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;
|
|
584
590
|
}
|
|
@@ -594,7 +600,7 @@ declare module 'fs' {
|
|
|
594
600
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
595
601
|
*/
|
|
596
602
|
export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
597
|
-
export function lstat(path: PathLike, options: StatOptions & { bigint?: false } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
603
|
+
export function lstat(path: PathLike, options: StatOptions & { bigint?: false | undefined } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
598
604
|
export function lstat(path: PathLike, options: StatOptions & { bigint: true }, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void;
|
|
599
605
|
export function lstat(path: PathLike, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
|
|
600
606
|
|
|
@@ -604,7 +610,7 @@ declare module 'fs' {
|
|
|
604
610
|
* Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
|
|
605
611
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
606
612
|
*/
|
|
607
|
-
function __promisify__(path: PathLike, options?: StatOptions & { bigint?: false }): Promise<Stats>;
|
|
613
|
+
function __promisify__(path: PathLike, options?: StatOptions & { bigint?: false | undefined }): Promise<Stats>;
|
|
608
614
|
function __promisify__(path: PathLike, options: StatOptions & { bigint: true }): Promise<BigIntStats>;
|
|
609
615
|
function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
|
|
610
616
|
}
|
|
@@ -684,7 +690,7 @@ declare module 'fs' {
|
|
|
684
690
|
*/
|
|
685
691
|
export function readlink(
|
|
686
692
|
path: PathLike,
|
|
687
|
-
options:
|
|
693
|
+
options: EncodingOption,
|
|
688
694
|
callback: (err: NodeJS.ErrnoException | null, linkString: string) => void
|
|
689
695
|
): void;
|
|
690
696
|
|
|
@@ -700,7 +706,7 @@ declare module 'fs' {
|
|
|
700
706
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
701
707
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
702
708
|
*/
|
|
703
|
-
export function readlink(path: PathLike, options:
|
|
709
|
+
export function readlink(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void): void;
|
|
704
710
|
|
|
705
711
|
/**
|
|
706
712
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
@@ -715,7 +721,7 @@ declare module 'fs' {
|
|
|
715
721
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
716
722
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
717
723
|
*/
|
|
718
|
-
function __promisify__(path: PathLike, options?:
|
|
724
|
+
function __promisify__(path: PathLike, options?: EncodingOption): Promise<string>;
|
|
719
725
|
|
|
720
726
|
/**
|
|
721
727
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
@@ -729,7 +735,7 @@ declare module 'fs' {
|
|
|
729
735
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
730
736
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
731
737
|
*/
|
|
732
|
-
function __promisify__(path: PathLike, options?:
|
|
738
|
+
function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
|
|
733
739
|
}
|
|
734
740
|
|
|
735
741
|
/**
|
|
@@ -737,7 +743,7 @@ declare module 'fs' {
|
|
|
737
743
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
738
744
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
739
745
|
*/
|
|
740
|
-
export function readlinkSync(path: PathLike, options?:
|
|
746
|
+
export function readlinkSync(path: PathLike, options?: EncodingOption): string;
|
|
741
747
|
|
|
742
748
|
/**
|
|
743
749
|
* Synchronous readlink(2) - read value of a symbolic link.
|
|
@@ -751,7 +757,7 @@ declare module 'fs' {
|
|
|
751
757
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
752
758
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
753
759
|
*/
|
|
754
|
-
export function readlinkSync(path: PathLike, options?:
|
|
760
|
+
export function readlinkSync(path: PathLike, options?: EncodingOption): string | Buffer;
|
|
755
761
|
|
|
756
762
|
/**
|
|
757
763
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
@@ -760,7 +766,7 @@ declare module 'fs' {
|
|
|
760
766
|
*/
|
|
761
767
|
export function realpath(
|
|
762
768
|
path: PathLike,
|
|
763
|
-
options:
|
|
769
|
+
options: EncodingOption,
|
|
764
770
|
callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
|
|
765
771
|
): void;
|
|
766
772
|
|
|
@@ -776,7 +782,7 @@ declare module 'fs' {
|
|
|
776
782
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
777
783
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
778
784
|
*/
|
|
779
|
-
export function realpath(path: PathLike, options:
|
|
785
|
+
export function realpath(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
|
|
780
786
|
|
|
781
787
|
/**
|
|
782
788
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
@@ -791,7 +797,7 @@ declare module 'fs' {
|
|
|
791
797
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
792
798
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
793
799
|
*/
|
|
794
|
-
function __promisify__(path: PathLike, options?:
|
|
800
|
+
function __promisify__(path: PathLike, options?: EncodingOption): Promise<string>;
|
|
795
801
|
|
|
796
802
|
/**
|
|
797
803
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
@@ -805,15 +811,15 @@ declare module 'fs' {
|
|
|
805
811
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
806
812
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
807
813
|
*/
|
|
808
|
-
function __promisify__(path: PathLike, options?:
|
|
814
|
+
function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
|
|
809
815
|
|
|
810
816
|
function native(
|
|
811
817
|
path: PathLike,
|
|
812
|
-
options:
|
|
818
|
+
options: EncodingOption,
|
|
813
819
|
callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
|
|
814
820
|
): void;
|
|
815
821
|
function native(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
|
|
816
|
-
function native(path: PathLike, options:
|
|
822
|
+
function native(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
|
|
817
823
|
function native(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
|
|
818
824
|
}
|
|
819
825
|
|
|
@@ -822,7 +828,7 @@ declare module 'fs' {
|
|
|
822
828
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
823
829
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
824
830
|
*/
|
|
825
|
-
export function realpathSync(path: PathLike, options?:
|
|
831
|
+
export function realpathSync(path: PathLike, options?: EncodingOption): string;
|
|
826
832
|
|
|
827
833
|
/**
|
|
828
834
|
* Synchronous realpath(3) - return the canonicalized absolute pathname.
|
|
@@ -836,12 +842,12 @@ declare module 'fs' {
|
|
|
836
842
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
837
843
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
838
844
|
*/
|
|
839
|
-
export function realpathSync(path: PathLike, options?:
|
|
845
|
+
export function realpathSync(path: PathLike, options?: EncodingOption): string | Buffer;
|
|
840
846
|
|
|
841
847
|
export namespace realpathSync {
|
|
842
|
-
function native(path: PathLike, options?:
|
|
848
|
+
function native(path: PathLike, options?: EncodingOption): string;
|
|
843
849
|
function native(path: PathLike, options: BufferEncodingOption): Buffer;
|
|
844
|
-
function native(path: PathLike, options?:
|
|
850
|
+
function native(path: PathLike, options?: EncodingOption): string | Buffer;
|
|
845
851
|
}
|
|
846
852
|
|
|
847
853
|
/**
|
|
@@ -874,13 +880,23 @@ declare module 'fs' {
|
|
|
874
880
|
* `true`.
|
|
875
881
|
* @default 0
|
|
876
882
|
*/
|
|
877
|
-
maxRetries?: number;
|
|
883
|
+
maxRetries?: number | undefined;
|
|
884
|
+
/**
|
|
885
|
+
* @deprecated since v14.14.0 In future versions of Node.js and will trigger a warning
|
|
886
|
+
* `fs.rmdir(path, { recursive: true })` will throw if `path` does not exist or is a file.
|
|
887
|
+
* Use `fs.rm(path, { recursive: true, force: true })` instead.
|
|
888
|
+
*
|
|
889
|
+
* If `true`, perform a recursive directory removal. In
|
|
890
|
+
* recursive mode soperations are retried on failure.
|
|
891
|
+
* @default false
|
|
892
|
+
*/
|
|
893
|
+
recursive?: boolean | undefined;
|
|
878
894
|
/**
|
|
879
895
|
* The amount of time in milliseconds to wait between retries.
|
|
880
896
|
* This option is ignored if the `recursive` option is not `true`.
|
|
881
897
|
* @default 100
|
|
882
898
|
*/
|
|
883
|
-
retryDelay?: number;
|
|
899
|
+
retryDelay?: number | undefined;
|
|
884
900
|
}
|
|
885
901
|
|
|
886
902
|
/**
|
|
@@ -910,7 +926,7 @@ declare module 'fs' {
|
|
|
910
926
|
* When `true`, exceptions will be ignored if `path` does not exist.
|
|
911
927
|
* @default false
|
|
912
928
|
*/
|
|
913
|
-
force?: boolean;
|
|
929
|
+
force?: boolean | undefined;
|
|
914
930
|
/**
|
|
915
931
|
* If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
|
|
916
932
|
* `EPERM` error is encountered, Node.js will retry the operation with a linear
|
|
@@ -919,19 +935,19 @@ declare module 'fs' {
|
|
|
919
935
|
* `true`.
|
|
920
936
|
* @default 0
|
|
921
937
|
*/
|
|
922
|
-
maxRetries?: number;
|
|
938
|
+
maxRetries?: number | undefined;
|
|
923
939
|
/**
|
|
924
940
|
* If `true`, perform a recursive directory removal. In
|
|
925
941
|
* recursive mode, operations are retried on failure.
|
|
926
942
|
* @default false
|
|
927
943
|
*/
|
|
928
|
-
recursive?: boolean;
|
|
944
|
+
recursive?: boolean | undefined;
|
|
929
945
|
/**
|
|
930
946
|
* The amount of time in milliseconds to wait between retries.
|
|
931
947
|
* This option is ignored if the `recursive` option is not `true`.
|
|
932
948
|
* @default 100
|
|
933
949
|
*/
|
|
934
|
-
retryDelay?: number;
|
|
950
|
+
retryDelay?: number | undefined;
|
|
935
951
|
}
|
|
936
952
|
|
|
937
953
|
/**
|
|
@@ -959,12 +975,12 @@ declare module 'fs' {
|
|
|
959
975
|
* If a folder was created, the path to the first created folder will be returned.
|
|
960
976
|
* @default false
|
|
961
977
|
*/
|
|
962
|
-
recursive?: boolean;
|
|
978
|
+
recursive?: boolean | undefined;
|
|
963
979
|
/**
|
|
964
980
|
* A file mode. If a string is passed, it is parsed as an octal integer. If not specified
|
|
965
981
|
* @default 0o777
|
|
966
982
|
*/
|
|
967
|
-
mode?: Mode;
|
|
983
|
+
mode?: Mode | undefined;
|
|
968
984
|
}
|
|
969
985
|
|
|
970
986
|
/**
|
|
@@ -981,7 +997,7 @@ declare module 'fs' {
|
|
|
981
997
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
|
982
998
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
|
983
999
|
*/
|
|
984
|
-
export function mkdir(path: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null | undefined, callback: NoParamCallback): void;
|
|
1000
|
+
export function mkdir(path: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false | undefined; }) | null | undefined, callback: NoParamCallback): void;
|
|
985
1001
|
|
|
986
1002
|
/**
|
|
987
1003
|
* Asynchronous mkdir(2) - create a directory.
|
|
@@ -1013,7 +1029,7 @@ declare module 'fs' {
|
|
|
1013
1029
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
|
1014
1030
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
|
1015
1031
|
*/
|
|
1016
|
-
function __promisify__(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null): Promise<void>;
|
|
1032
|
+
function __promisify__(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false | undefined; }) | null): Promise<void>;
|
|
1017
1033
|
|
|
1018
1034
|
/**
|
|
1019
1035
|
* Asynchronous mkdir(2) - create a directory.
|
|
@@ -1038,7 +1054,7 @@ declare module 'fs' {
|
|
|
1038
1054
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
|
1039
1055
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
|
1040
1056
|
*/
|
|
1041
|
-
export function mkdirSync(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null): void;
|
|
1057
|
+
export function mkdirSync(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false | undefined; }) | null): void;
|
|
1042
1058
|
|
|
1043
1059
|
/**
|
|
1044
1060
|
* Synchronous mkdir(2) - create a directory.
|
|
@@ -1053,7 +1069,7 @@ declare module 'fs' {
|
|
|
1053
1069
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1054
1070
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1055
1071
|
*/
|
|
1056
|
-
export function mkdtemp(prefix: string, options:
|
|
1072
|
+
export function mkdtemp(prefix: string, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
|
|
1057
1073
|
|
|
1058
1074
|
/**
|
|
1059
1075
|
* Asynchronously creates a unique temporary directory.
|
|
@@ -1067,7 +1083,7 @@ declare module 'fs' {
|
|
|
1067
1083
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1068
1084
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1069
1085
|
*/
|
|
1070
|
-
export function mkdtemp(prefix: string, options:
|
|
1086
|
+
export function mkdtemp(prefix: string, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void): void;
|
|
1071
1087
|
|
|
1072
1088
|
/**
|
|
1073
1089
|
* Asynchronously creates a unique temporary directory.
|
|
@@ -1082,7 +1098,7 @@ declare module 'fs' {
|
|
|
1082
1098
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1083
1099
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1084
1100
|
*/
|
|
1085
|
-
function __promisify__(prefix: string, options?:
|
|
1101
|
+
function __promisify__(prefix: string, options?: EncodingOption): Promise<string>;
|
|
1086
1102
|
|
|
1087
1103
|
/**
|
|
1088
1104
|
* Asynchronously creates a unique temporary directory.
|
|
@@ -1096,7 +1112,7 @@ declare module 'fs' {
|
|
|
1096
1112
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1097
1113
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1098
1114
|
*/
|
|
1099
|
-
function __promisify__(prefix: string, options?:
|
|
1115
|
+
function __promisify__(prefix: string, options?: EncodingOption): Promise<string | Buffer>;
|
|
1100
1116
|
}
|
|
1101
1117
|
|
|
1102
1118
|
/**
|
|
@@ -1104,7 +1120,7 @@ declare module 'fs' {
|
|
|
1104
1120
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1105
1121
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1106
1122
|
*/
|
|
1107
|
-
export function mkdtempSync(prefix: string, options?:
|
|
1123
|
+
export function mkdtempSync(prefix: string, options?: EncodingOption): string;
|
|
1108
1124
|
|
|
1109
1125
|
/**
|
|
1110
1126
|
* Synchronously creates a unique temporary directory.
|
|
@@ -1118,7 +1134,7 @@ declare module 'fs' {
|
|
|
1118
1134
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1119
1135
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1120
1136
|
*/
|
|
1121
|
-
export function mkdtempSync(prefix: string, options?:
|
|
1137
|
+
export function mkdtempSync(prefix: string, options?: EncodingOption): string | Buffer;
|
|
1122
1138
|
|
|
1123
1139
|
/**
|
|
1124
1140
|
* Asynchronous readdir(3) - read a directory.
|
|
@@ -1127,7 +1143,7 @@ declare module 'fs' {
|
|
|
1127
1143
|
*/
|
|
1128
1144
|
export function readdir(
|
|
1129
1145
|
path: PathLike,
|
|
1130
|
-
options: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | undefined | null,
|
|
1146
|
+
options: { encoding: BufferEncoding | null; withFileTypes?: false | undefined } | BufferEncoding | undefined | null,
|
|
1131
1147
|
callback: (err: NodeJS.ErrnoException | null, files: string[]) => void,
|
|
1132
1148
|
): void;
|
|
1133
1149
|
|
|
@@ -1136,7 +1152,11 @@ declare module 'fs' {
|
|
|
1136
1152
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1137
1153
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1138
1154
|
*/
|
|
1139
|
-
export function readdir(
|
|
1155
|
+
export function readdir(
|
|
1156
|
+
path: PathLike,
|
|
1157
|
+
options: { encoding: "buffer"; withFileTypes?: false | undefined } | "buffer",
|
|
1158
|
+
callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void
|
|
1159
|
+
): void;
|
|
1140
1160
|
|
|
1141
1161
|
/**
|
|
1142
1162
|
* Asynchronous readdir(3) - read a directory.
|
|
@@ -1145,7 +1165,7 @@ declare module 'fs' {
|
|
|
1145
1165
|
*/
|
|
1146
1166
|
export function readdir(
|
|
1147
1167
|
path: PathLike,
|
|
1148
|
-
options:
|
|
1168
|
+
options: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | undefined | null,
|
|
1149
1169
|
callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void,
|
|
1150
1170
|
): void;
|
|
1151
1171
|
|
|
@@ -1160,7 +1180,7 @@ declare module 'fs' {
|
|
|
1160
1180
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1161
1181
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
|
|
1162
1182
|
*/
|
|
1163
|
-
export function readdir(path: PathLike, options:
|
|
1183
|
+
export function readdir(path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true }, callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void): void;
|
|
1164
1184
|
|
|
1165
1185
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1166
1186
|
export namespace readdir {
|
|
@@ -1169,28 +1189,28 @@ declare module 'fs' {
|
|
|
1169
1189
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1170
1190
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1171
1191
|
*/
|
|
1172
|
-
function __promisify__(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): Promise<string[]>;
|
|
1192
|
+
function __promisify__(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[]>;
|
|
1173
1193
|
|
|
1174
1194
|
/**
|
|
1175
1195
|
* Asynchronous readdir(3) - read a directory.
|
|
1176
1196
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1177
1197
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1178
1198
|
*/
|
|
1179
|
-
function __promisify__(path: PathLike, options: "buffer" | { encoding: "buffer"; withFileTypes?: false }): Promise<Buffer[]>;
|
|
1199
|
+
function __promisify__(path: PathLike, options: "buffer" | { encoding: "buffer"; withFileTypes?: false | undefined }): Promise<Buffer[]>;
|
|
1180
1200
|
|
|
1181
1201
|
/**
|
|
1182
1202
|
* Asynchronous readdir(3) - read a directory.
|
|
1183
1203
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1184
1204
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1185
1205
|
*/
|
|
1186
|
-
function __promisify__(path: PathLike, options?:
|
|
1206
|
+
function __promisify__(path: PathLike, options?: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[] | Buffer[]>;
|
|
1187
1207
|
|
|
1188
1208
|
/**
|
|
1189
1209
|
* Asynchronous readdir(3) - read a directory.
|
|
1190
1210
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1191
1211
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent
|
|
1192
1212
|
*/
|
|
1193
|
-
function __promisify__(path: PathLike, options:
|
|
1213
|
+
function __promisify__(path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true }): Promise<Dirent[]>;
|
|
1194
1214
|
}
|
|
1195
1215
|
|
|
1196
1216
|
/**
|
|
@@ -1198,28 +1218,28 @@ declare module 'fs' {
|
|
|
1198
1218
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1199
1219
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1200
1220
|
*/
|
|
1201
|
-
export function readdirSync(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): string[];
|
|
1221
|
+
export function readdirSync(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false | undefined } | BufferEncoding | null): string[];
|
|
1202
1222
|
|
|
1203
1223
|
/**
|
|
1204
1224
|
* Synchronous readdir(3) - read a directory.
|
|
1205
1225
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1206
1226
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1207
1227
|
*/
|
|
1208
|
-
export function readdirSync(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer"): Buffer[];
|
|
1228
|
+
export function readdirSync(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false | undefined } | "buffer"): Buffer[];
|
|
1209
1229
|
|
|
1210
1230
|
/**
|
|
1211
1231
|
* Synchronous readdir(3) - read a directory.
|
|
1212
1232
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1213
1233
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1214
1234
|
*/
|
|
1215
|
-
export function readdirSync(path: PathLike, options?:
|
|
1235
|
+
export function readdirSync(path: PathLike, options?: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): string[] | Buffer[];
|
|
1216
1236
|
|
|
1217
1237
|
/**
|
|
1218
1238
|
* Synchronous readdir(3) - read a directory.
|
|
1219
1239
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1220
1240
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
|
|
1221
1241
|
*/
|
|
1222
|
-
export function readdirSync(path: PathLike, options:
|
|
1242
|
+
export function readdirSync(path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true }): Dirent[];
|
|
1223
1243
|
|
|
1224
1244
|
/**
|
|
1225
1245
|
* Asynchronous close(2) - close a file descriptor.
|
|
@@ -1278,7 +1298,7 @@ declare module 'fs' {
|
|
|
1278
1298
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
1279
1299
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
1280
1300
|
*/
|
|
1281
|
-
export function utimes(path: PathLike, atime:
|
|
1301
|
+
export function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
|
|
1282
1302
|
|
|
1283
1303
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1284
1304
|
export namespace utimes {
|
|
@@ -1288,7 +1308,7 @@ declare module 'fs' {
|
|
|
1288
1308
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
1289
1309
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
1290
1310
|
*/
|
|
1291
|
-
function __promisify__(path: PathLike, atime:
|
|
1311
|
+
function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
|
|
1292
1312
|
}
|
|
1293
1313
|
|
|
1294
1314
|
/**
|
|
@@ -1297,7 +1317,7 @@ declare module 'fs' {
|
|
|
1297
1317
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
1298
1318
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
1299
1319
|
*/
|
|
1300
|
-
export function utimesSync(path: PathLike, atime:
|
|
1320
|
+
export function utimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
|
|
1301
1321
|
|
|
1302
1322
|
/**
|
|
1303
1323
|
* Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
|
|
@@ -1305,7 +1325,7 @@ declare module 'fs' {
|
|
|
1305
1325
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
1306
1326
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
1307
1327
|
*/
|
|
1308
|
-
export function futimes(fd: number, atime:
|
|
1328
|
+
export function futimes(fd: number, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
|
|
1309
1329
|
|
|
1310
1330
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1311
1331
|
export namespace futimes {
|
|
@@ -1315,7 +1335,7 @@ declare module 'fs' {
|
|
|
1315
1335
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
1316
1336
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
1317
1337
|
*/
|
|
1318
|
-
function __promisify__(fd: number, atime:
|
|
1338
|
+
function __promisify__(fd: number, atime: TimeLike, mtime: TimeLike): Promise<void>;
|
|
1319
1339
|
}
|
|
1320
1340
|
|
|
1321
1341
|
/**
|
|
@@ -1324,7 +1344,7 @@ declare module 'fs' {
|
|
|
1324
1344
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
1325
1345
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
1326
1346
|
*/
|
|
1327
|
-
export function futimesSync(fd: number, atime:
|
|
1347
|
+
export function futimesSync(fd: number, atime: TimeLike, mtime: TimeLike): void;
|
|
1328
1348
|
|
|
1329
1349
|
/**
|
|
1330
1350
|
* Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
|
|
@@ -1511,15 +1531,15 @@ declare module 'fs' {
|
|
|
1511
1531
|
/**
|
|
1512
1532
|
* @default 0
|
|
1513
1533
|
*/
|
|
1514
|
-
offset?: number;
|
|
1534
|
+
offset?: number | undefined;
|
|
1515
1535
|
/**
|
|
1516
1536
|
* @default `length of buffer`
|
|
1517
1537
|
*/
|
|
1518
|
-
length?: number;
|
|
1538
|
+
length?: number | undefined;
|
|
1519
1539
|
/**
|
|
1520
1540
|
* @default null
|
|
1521
1541
|
*/
|
|
1522
|
-
position?: ReadPosition | null;
|
|
1542
|
+
position?: ReadPosition | null | undefined;
|
|
1523
1543
|
}
|
|
1524
1544
|
|
|
1525
1545
|
/**
|
|
@@ -1546,8 +1566,8 @@ declare module 'fs' {
|
|
|
1546
1566
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1547
1567
|
*/
|
|
1548
1568
|
export function readFile(
|
|
1549
|
-
path:
|
|
1550
|
-
options: { encoding?: null; flag?: string; } & Abortable | undefined | null,
|
|
1569
|
+
path: PathOrFileDescriptor,
|
|
1570
|
+
options: { encoding?: null | undefined; flag?: string | undefined; } & Abortable | undefined | null,
|
|
1551
1571
|
callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void,
|
|
1552
1572
|
): void;
|
|
1553
1573
|
|
|
@@ -1559,8 +1579,8 @@ declare module 'fs' {
|
|
|
1559
1579
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1560
1580
|
*/
|
|
1561
1581
|
export function readFile(
|
|
1562
|
-
path:
|
|
1563
|
-
options: { encoding: BufferEncoding; flag?: string; } & Abortable | string,
|
|
1582
|
+
path: PathOrFileDescriptor,
|
|
1583
|
+
options: { encoding: BufferEncoding; flag?: string | undefined; } & Abortable | string,
|
|
1564
1584
|
callback: (err: NodeJS.ErrnoException | null, data: string) => void,
|
|
1565
1585
|
): void;
|
|
1566
1586
|
|
|
@@ -1572,9 +1592,8 @@ declare module 'fs' {
|
|
|
1572
1592
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1573
1593
|
*/
|
|
1574
1594
|
export function readFile(
|
|
1575
|
-
path:
|
|
1576
|
-
|
|
1577
|
-
options: BaseEncodingOptions & { flag?: string; } & Abortable | string | undefined | null,
|
|
1595
|
+
path: PathOrFileDescriptor,
|
|
1596
|
+
options: ObjectEncodingOptions & { flag?: string | undefined; } & Abortable | string | undefined | null,
|
|
1578
1597
|
callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void,
|
|
1579
1598
|
): void;
|
|
1580
1599
|
|
|
@@ -1583,7 +1602,7 @@ declare module 'fs' {
|
|
|
1583
1602
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1584
1603
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
1585
1604
|
*/
|
|
1586
|
-
export function readFile(path:
|
|
1605
|
+
export function readFile(path: PathOrFileDescriptor, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
|
|
1587
1606
|
|
|
1588
1607
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1589
1608
|
export namespace readFile {
|
|
@@ -1594,7 +1613,7 @@ declare module 'fs' {
|
|
|
1594
1613
|
* @param options An object that may contain an optional flag.
|
|
1595
1614
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1596
1615
|
*/
|
|
1597
|
-
function __promisify__(path:
|
|
1616
|
+
function __promisify__(path: PathOrFileDescriptor, options?: { encoding?: null | undefined; flag?: string | undefined; } | null): Promise<Buffer>;
|
|
1598
1617
|
|
|
1599
1618
|
/**
|
|
1600
1619
|
* Asynchronously reads the entire contents of a file.
|
|
@@ -1604,7 +1623,7 @@ declare module 'fs' {
|
|
|
1604
1623
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
1605
1624
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1606
1625
|
*/
|
|
1607
|
-
function __promisify__(path:
|
|
1626
|
+
function __promisify__(path: PathOrFileDescriptor, options: { encoding: BufferEncoding; flag?: string | undefined; } | string): Promise<string>;
|
|
1608
1627
|
|
|
1609
1628
|
/**
|
|
1610
1629
|
* Asynchronously reads the entire contents of a file.
|
|
@@ -1614,7 +1633,7 @@ declare module 'fs' {
|
|
|
1614
1633
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
1615
1634
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1616
1635
|
*/
|
|
1617
|
-
function __promisify__(path:
|
|
1636
|
+
function __promisify__(path: PathOrFileDescriptor, options?: ObjectEncodingOptions & { flag?: string | undefined; } | string | null): Promise<string | Buffer>;
|
|
1618
1637
|
}
|
|
1619
1638
|
|
|
1620
1639
|
/**
|
|
@@ -1623,7 +1642,7 @@ declare module 'fs' {
|
|
|
1623
1642
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
1624
1643
|
* @param options An object that may contain an optional flag. If a flag is not provided, it defaults to `'r'`.
|
|
1625
1644
|
*/
|
|
1626
|
-
export function readFileSync(path:
|
|
1645
|
+
export function readFileSync(path: PathOrFileDescriptor, options?: { encoding?: null | undefined; flag?: string | undefined; } | null): Buffer;
|
|
1627
1646
|
|
|
1628
1647
|
/**
|
|
1629
1648
|
* Synchronously reads the entire contents of a file.
|
|
@@ -1632,7 +1651,7 @@ declare module 'fs' {
|
|
|
1632
1651
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
1633
1652
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1634
1653
|
*/
|
|
1635
|
-
export function readFileSync(path:
|
|
1654
|
+
export function readFileSync(path: PathOrFileDescriptor, options: { encoding: BufferEncoding; flag?: string | undefined; } | BufferEncoding): string;
|
|
1636
1655
|
|
|
1637
1656
|
/**
|
|
1638
1657
|
* Synchronously reads the entire contents of a file.
|
|
@@ -1641,9 +1660,9 @@ declare module 'fs' {
|
|
|
1641
1660
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
1642
1661
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1643
1662
|
*/
|
|
1644
|
-
export function readFileSync(path:
|
|
1663
|
+
export function readFileSync(path: PathOrFileDescriptor, options?: ObjectEncodingOptions & { flag?: string | undefined; } | BufferEncoding | null): string | Buffer;
|
|
1645
1664
|
|
|
1646
|
-
export type WriteFileOptions = (
|
|
1665
|
+
export type WriteFileOptions = (ObjectEncodingOptions & Abortable & { mode?: Mode | undefined; flag?: string | undefined; }) | string | null;
|
|
1647
1666
|
|
|
1648
1667
|
/**
|
|
1649
1668
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
|
@@ -1656,7 +1675,7 @@ declare module 'fs' {
|
|
|
1656
1675
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
1657
1676
|
* If `flag` is not supplied, the default of `'w'` is used.
|
|
1658
1677
|
*/
|
|
1659
|
-
export function writeFile(path:
|
|
1678
|
+
export function writeFile(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
1660
1679
|
|
|
1661
1680
|
/**
|
|
1662
1681
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
|
@@ -1664,7 +1683,7 @@ declare module 'fs' {
|
|
|
1664
1683
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
1665
1684
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
|
1666
1685
|
*/
|
|
1667
|
-
export function writeFile(path:
|
|
1686
|
+
export function writeFile(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void;
|
|
1668
1687
|
|
|
1669
1688
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1670
1689
|
export namespace writeFile {
|
|
@@ -1680,7 +1699,7 @@ declare module 'fs' {
|
|
|
1680
1699
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
1681
1700
|
* If `flag` is not supplied, the default of `'w'` is used.
|
|
1682
1701
|
*/
|
|
1683
|
-
function __promisify__(path:
|
|
1702
|
+
function __promisify__(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): Promise<void>;
|
|
1684
1703
|
}
|
|
1685
1704
|
|
|
1686
1705
|
/**
|
|
@@ -1694,7 +1713,7 @@ declare module 'fs' {
|
|
|
1694
1713
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
1695
1714
|
* If `flag` is not supplied, the default of `'w'` is used.
|
|
1696
1715
|
*/
|
|
1697
|
-
export function writeFileSync(path:
|
|
1716
|
+
export function writeFileSync(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void;
|
|
1698
1717
|
|
|
1699
1718
|
/**
|
|
1700
1719
|
* Asynchronously append data to a file, creating the file if it does not exist.
|
|
@@ -1707,7 +1726,7 @@ declare module 'fs' {
|
|
|
1707
1726
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
1708
1727
|
* If `flag` is not supplied, the default of `'a'` is used.
|
|
1709
1728
|
*/
|
|
1710
|
-
export function appendFile(file:
|
|
1729
|
+
export function appendFile(file: PathOrFileDescriptor, data: string | Uint8Array, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
1711
1730
|
|
|
1712
1731
|
/**
|
|
1713
1732
|
* Asynchronously append data to a file, creating the file if it does not exist.
|
|
@@ -1715,7 +1734,7 @@ declare module 'fs' {
|
|
|
1715
1734
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
1716
1735
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
|
1717
1736
|
*/
|
|
1718
|
-
export function appendFile(file:
|
|
1737
|
+
export function appendFile(file: PathOrFileDescriptor, data: string | Uint8Array, callback: NoParamCallback): void;
|
|
1719
1738
|
|
|
1720
1739
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1721
1740
|
export namespace appendFile {
|
|
@@ -1731,7 +1750,7 @@ declare module 'fs' {
|
|
|
1731
1750
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
1732
1751
|
* If `flag` is not supplied, the default of `'a'` is used.
|
|
1733
1752
|
*/
|
|
1734
|
-
function __promisify__(file:
|
|
1753
|
+
function __promisify__(file: PathOrFileDescriptor, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
|
|
1735
1754
|
}
|
|
1736
1755
|
|
|
1737
1756
|
/**
|
|
@@ -1745,12 +1764,12 @@ declare module 'fs' {
|
|
|
1745
1764
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
1746
1765
|
* If `flag` is not supplied, the default of `'a'` is used.
|
|
1747
1766
|
*/
|
|
1748
|
-
export function appendFileSync(file:
|
|
1767
|
+
export function appendFileSync(file: PathOrFileDescriptor, data: string | Uint8Array, options?: WriteFileOptions): void;
|
|
1749
1768
|
|
|
1750
1769
|
/**
|
|
1751
1770
|
* Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
|
|
1752
1771
|
*/
|
|
1753
|
-
export function watchFile(filename: PathLike, options: { persistent?: boolean; interval?: number; } | undefined, listener: (curr: Stats, prev: Stats) => void): void;
|
|
1772
|
+
export function watchFile(filename: PathLike, options: { persistent?: boolean | undefined; interval?: number | undefined; } | undefined, listener: (curr: Stats, prev: Stats) => void): void;
|
|
1754
1773
|
|
|
1755
1774
|
/**
|
|
1756
1775
|
* Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
|
|
@@ -1765,9 +1784,9 @@ declare module 'fs' {
|
|
|
1765
1784
|
export function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
|
|
1766
1785
|
|
|
1767
1786
|
export interface WatchOptions extends Abortable {
|
|
1768
|
-
encoding?: BufferEncoding | "buffer";
|
|
1769
|
-
persistent?: boolean;
|
|
1770
|
-
recursive?: boolean;
|
|
1787
|
+
encoding?: BufferEncoding | "buffer" | undefined;
|
|
1788
|
+
persistent?: boolean | undefined;
|
|
1789
|
+
recursive?: boolean | undefined;
|
|
1771
1790
|
}
|
|
1772
1791
|
|
|
1773
1792
|
export type WatchListener<T> = (event: "rename" | "change", filename: T) => void;
|
|
@@ -2026,21 +2045,21 @@ declare module 'fs' {
|
|
|
2026
2045
|
export function accessSync(path: PathLike, mode?: number): void;
|
|
2027
2046
|
|
|
2028
2047
|
interface StreamOptions {
|
|
2029
|
-
flags?: string;
|
|
2030
|
-
encoding?: BufferEncoding;
|
|
2031
|
-
fd?: number | promises.FileHandle;
|
|
2032
|
-
mode?: number;
|
|
2033
|
-
autoClose?: boolean;
|
|
2048
|
+
flags?: string | undefined;
|
|
2049
|
+
encoding?: BufferEncoding | undefined;
|
|
2050
|
+
fd?: number | promises.FileHandle | undefined;
|
|
2051
|
+
mode?: number | undefined;
|
|
2052
|
+
autoClose?: boolean | undefined;
|
|
2034
2053
|
/**
|
|
2035
2054
|
* @default false
|
|
2036
2055
|
*/
|
|
2037
|
-
emitClose?: boolean;
|
|
2038
|
-
start?: number;
|
|
2039
|
-
highWaterMark?: number;
|
|
2056
|
+
emitClose?: boolean | undefined;
|
|
2057
|
+
start?: number | undefined;
|
|
2058
|
+
highWaterMark?: number | undefined;
|
|
2040
2059
|
}
|
|
2041
2060
|
|
|
2042
2061
|
interface ReadStreamOptions extends StreamOptions {
|
|
2043
|
-
end?: number;
|
|
2062
|
+
end?: number | undefined;
|
|
2044
2063
|
}
|
|
2045
2064
|
|
|
2046
2065
|
/**
|
|
@@ -2187,14 +2206,14 @@ declare module 'fs' {
|
|
|
2187
2206
|
export function readvSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
|
|
2188
2207
|
|
|
2189
2208
|
export interface OpenDirOptions {
|
|
2190
|
-
encoding?: BufferEncoding;
|
|
2209
|
+
encoding?: BufferEncoding | undefined;
|
|
2191
2210
|
/**
|
|
2192
2211
|
* Number of directory entries that are buffered
|
|
2193
2212
|
* internally when reading from the directory. Higher values lead to better
|
|
2194
2213
|
* performance but higher memory usage.
|
|
2195
2214
|
* @default 32
|
|
2196
2215
|
*/
|
|
2197
|
-
bufferSize?: number;
|
|
2216
|
+
bufferSize?: number | undefined;
|
|
2198
2217
|
}
|
|
2199
2218
|
|
|
2200
2219
|
export function opendirSync(path: string, options?: OpenDirOptions): Dir;
|
|
@@ -2221,8 +2240,8 @@ declare module 'fs' {
|
|
|
2221
2240
|
}
|
|
2222
2241
|
|
|
2223
2242
|
export interface StatOptions {
|
|
2224
|
-
bigint?: boolean;
|
|
2225
|
-
throwIfNoEntry?: boolean;
|
|
2243
|
+
bigint?: boolean | undefined;
|
|
2244
|
+
throwIfNoEntry?: boolean | undefined;
|
|
2226
2245
|
}
|
|
2227
2246
|
}
|
|
2228
2247
|
|