/
index.d.ts
1011 lines (896 loc) · 28.2 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import type { PathLike, Stats } from "fs";
export interface RmOptions {
/**
* When `true`, exceptions will be ignored if `path` does not exist.
* @default false
*/
force?: boolean | undefined;
/**
* If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
* `EPERM` error is encountered, Node.js will retry the operation with a linear
* backoff wait of `retryDelay` ms longer on each try. This option represents the
* number of retries. This option is ignored if the `recursive` option is not
* `true`.
* @default 0
*/
maxRetries?: number | undefined;
/**
* If `true`, perform a recursive directory removal. In
* recursive mode, operations are retried on failure.
* @default false
*/
recursive?: boolean | undefined;
/**
* The amount of time in milliseconds to wait between retries.
* This option is ignored if the `recursive` option is not `true`.
* @default 100
*/
retryDelay?: number | undefined;
}
//#region create
/**
* @name createDirectory
* @description Asynchronous create a directory.
* @since 0.0.10
* @async
* @param {string|Buffer|URL} dirPath
* @param {number|string=} mode
* @param {boolean=} recursive
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function createDirectory(dirPath: PathLike, mode?: number | string, recursive?: boolean): Promise<true | Error>;
/**
* @name createFile
* @description Asynchronous create a file.
* @since 0.0.11
* @async
* @param {string|Buffer|URL} pathLike
* @param {number|string=} mode
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function createFile(pathLike: PathLike, mode?: number | string): Promise<true | Error>;
//#endregion
//#region dir
/**
* @name dirIsExecutable
* @description Directory can be executed by the calling process
* @since 0.0.5
* @async
* @param {string|Buffer|URL} pathToDir
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function dirIsExecutable(pathToDir: PathLike): Promise<true | Error>;
/**
* @name dirIsReadable
* @description Directory is visible to the calling process
* @since 0.0.1
* @async
* @param {string|Buffer|URL} pathToDir
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function dirIsReadable(pathToDir: PathLike): Promise<true | Error>;
/**
* @name dirIsVisible
* @description Directory is visible to the calling process
* @since 0.0.5
* @async
* @param {string|Buffer|URL} pathToDir
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function dirIsVisible(pathToDir: PathLike): Promise<true | Error>;
/**
* @name dirIsWritable
* @description Directory can be written by the calling process
* @since 0.0.1
* @async
* @param {string|Buffer|URL} pathToDir
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function dirIsWritable(pathToDir: PathLike): Promise<true | Error>;
/**
* @name dirIsEmpty
* @description Check If a directory is empty
* @since 0.1.33
* @async
* @param {string|Buffer|URL} pathToDir
* @param {boolean=} excludeSystemFiles
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function dirIsEmpty(pathToDir: PathLike, excludeSystemFiles: boolean): Promise<boolean | Error>;
//#endregion
//#region file
/**
* @name fileIsExecutable
* @description File can be executed by the calling process
* @since 0.0.5
* @async
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function fileIsExecutable(pathToFile: PathLike): Promise<true | Error>;
/**
* @name fileIsReadable
* @description File is visible to the calling process
* @since 0.0.1
* @async
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function fileIsReadable(pathToFile: PathLike): Promise<true | Error>;
/**
* @name fileIsVisible
* @description File is visible to the calling process
* @since 0.0.5
* @async
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function fileIsVisible(pathToFile: PathLike): Promise<true | Error>;
/**
* @name fileIsWritable
* @description File can be written by the calling process
* @since 0.0.1
* @async
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function fileIsWritable(pathToFile: PathLike): Promise<true | Error>;
/**
* @name fileTruncate
* @description Truncate a file to a specified length
* @since 0.0.6
* @async
* @param {string|Buffer|URL} pathToFile
* @param {number=} length
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function fileTruncate(pathToFile: PathLike, length?: number): Promise<true | Error>;
//#endregion
//#region info
/**
* @name hash
* @description Calculate hash.
* @since 0.2.3
* @async
* @param {string|Buffer|URL} pathToFile
* @param {string} algorithm
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
* @throws {TypeError} If algorithm is not supported.
*/
export function hash(pathToFile: PathLike, algorithm: string): Promise<string | Error>;
/**
* @name hashCrc32
* @description CRC32.
* @since 0.2.3
* @async
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
export function hashCrc32(pathToFile: PathLike): Promise<string | Error>;
/**
* @name hashMd5
* @description MD5.
* @since 0.2.3
* @async
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
export function hashMd5(pathToFile: PathLike): Promise<string | Error>;
/**
* @name hashSha1
* @description SHA-1.
* @since 0.2.3
* @async
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
export function hashSha1(pathToFile: PathLike): Promise<string | Error>;
/**
* @name hashSha256
* @description SHA-256.
* @since 0.2.3
* @async
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
export function hashSha256(pathToFile: PathLike): Promise<string | Error>;
/**
* @name size
* @description File size in bytes.
* @since 0.2.3
* @async
* @param {string|Buffer|URL} pathToFile
* @param {boolean=} [asString=false]
* @returns {Promise<number|string|Error|{name: string, message: string, stack?: string}>}
*/
export function size(pathToFile: PathLike, asString?: boolean): Promise<number | string | Error>;
//#endregion
//#region list
/**
* @name listContents
* @description Lists files and directories in path
* @since 0.1.32
* @async
* @param {string|Buffer|URL} pathToDir
* @param {boolean} [ignoreJunk=true]
* @returns {Promise<Array.<string>|Error|{name: string, message: string, stack?: string}>}
*/
export function listContents(pathToDir: PathLike, ignoreJunk?: boolean): Promise<string[] | Error>;
/**
* @name listDirectories
* @description Lists directories in path
* @since 0.1.32
* @async
* @param {string|Buffer|URL} pathToDir
* @returns {Promise<Array.<string>|Error|{name: string, message: string, stack?: string}>}
*/
export function listDirectories(pathToDir: PathLike): Promise<string[] | Error>;
/**
* @name listFiles
* @description Lists files in path
* @since 0.1.32
* @async
* @param {string|Buffer|URL} pathToDir
* @returns {Promise<Array.<string>|Error|{name: string, message: string, stack?: string}>}
*/
export function listFiles(pathToDir: PathLike): Promise<string[] | Error>;
//#endregion
//#region move
/**
* @name move
* @description Change the name or location of a file or directory.
* @since 0.1.29
* @param {string} pathFrom
* @param {string} pathTo
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function move(pathFrom: PathLike, pathTo: PathLike): Promise<true | Error>;
//#endregion
//#region path
/**
* @name absolutePathFrom
* @description Join all arguments together and normalize the resulting path.
* Creates absolute path from right to left until an absolute path is constructed.
* @since 0.1.5
* @param {string|Array.<string>} paths
* @param {...string} morePaths
* @returns {string}
*/
export function absolutePathFrom(paths: string | string[], ...morePaths: string[]): string;
/**
* @name fileExtension
* @description Get file extension.
* @since 0.1.1
* @param {string} path
* @returns {string}
*/
export function fileExtension(path: string): string;
/**
* @name fileName
* @description Return the file name without extension.
* @since 0.1.1
* @param {string} path
* @returns {string}
*/
export function fileName(path: string): string;
/**
* @name fileNameExt
* @description Return the last portion of a path.
* @since 0.1.1
* @param {string} path
* @returns {string}
*/
export function fileNameExt(path: string): string;
/**
* @name filePath
* @description Return the directory name of a path.
* @since 0.1.1
* @param {string} path
* @returns {string}
*/
export function filePath(path: string): string;
/**
* @name pathFrom
* @description Join all arguments together and normalize the resulting path.
* @since 0.1.3
* @param {string|Array.<string>} paths
* @param {...string} morePaths
* @returns {string}
*/
export function pathFrom(paths: string | string[], ...morePaths: string[]): string;
//#endregion
//#region read
/**
* @name readFileToBase64
* @description Asynchronously reads the entire contents of a file into string.
* @since 0.1.21
* @async
* @param {string|Buffer|URL} pathLike
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
export function readFileToBase64(pathLike: string): Promise<string | Error>;
/**
* @name readFileToBuffer
* @description Asynchronously reads the entire contents of a file into buffer.
* @since 0.1.19
* @async
* @param {string|Buffer|URL} pathLike
* @returns {Promise<Buffer|Error|{name: string, message: string, stack?: string}>}
*/
export function readFileToBuffer(pathLike: string): Promise<Buffer | Error>;
/**
* @name readFileToString
* @description Asynchronously reads the entire contents of a file into string.
* @since 0.1.7
* @async
* @param {string|Buffer|URL} pathLike
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
export function readFileToString(pathLike: string): Promise<string | Error>;
//#endregion
//#region remove
/**
* @name remove
* @description Removes a file or directory.
* @since 0.1.1
* @async
* @param {string} pathLike
* @returns {Promise<undefined|Error|{name: string, message: string, stack?: string}>}
*/
export function remove(pathLike: string): Promise<undefined | Error>;
/**
* @name removeNonBlocking
* @description Non-blocking remove of a file or directory.
* @since 0.1.18
* @sync
* @param {string} pathLike
* @returns {void}
*/
export function removeNonBlocking(pathLike: string): void;
/**
* @name removeSilent
* @description Removes files and directories (modeled on the standard POSIX rm utility).
* @summary Minimum Node version 14.14.0
* @since 0.1.36
* @async
* @param {string|Buffer|URL} pathLike
* @param {object=} options
* @returns {Promise<void>}
*/
export function removeSilent(pathLike: string, options?: RmOptions): Promise<void>;
//#endregion
//#region status
/**
* @name getLinkStatus
* @description Get file status unless `path` refers to a symbolic link, in which case the link itself is stat-ed, not the file that it refers to.
* @url http://man7.org/linux/man-pages/man2/lstat.2.html
* @since 1.1.0
* @async
* @param {string|Buffer|URL} path
* @returns {Promise<Array.<(object|undefined|Error|{name: string, message: string, stack?: string})>>}
*/
export function getLinkStatus(path: PathLike): Promise<[Stats?, Error?]>;
/**
* @name getStatus
* @description Get file status.
* @since 0.0.11
* @async
* @param {string|Buffer|URL} path
* @returns {Promise<[fs.Stats|undefined],[Error|{name: string, message: string, stack?: string}]>}
*/
export function getStatus(path: PathLike): Promise<[Stats?, Error?]>;
/**
* @name isDirExists
* @description Get directory status.
* @since 0.0.11
* @async
* @param {string|Buffer|URL} path
* @returns {Promise<boolean>}
*/
export function isDirExists(path: PathLike): Promise<boolean>;
/**
* @name isFileExists
* @description Get file status.
* @since 0.0.11
* @async
* @param {string|Buffer|URL} path
* @returns {Promise<boolean>}
*/
export function isFileExists(path: PathLike): Promise<boolean>;
/**
* @name isPathExists
* @description Get path status.
* @since 0.0.11
* @async
* @param {string|Buffer|URL} path
* @returns {Promise<boolean>}
*/
export function isPathExists(path: PathLike): Promise<boolean>;
//#endregion
//#region write
/**
* @name writeFile
* @description Asynchronously writes data to a file, replacing the file if it already exists.
* @since 0.0.10
* @async
* @param {string|Buffer|URL|FileHandle} filePath
* @param {string} data
* @param {*|null|string=} options
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function writeFile(
filePath: PathLike,
data: string,
options?: { encoding?: string | null; mode?: string | number; flag?: string | number },
): Promise<true | Error>;
/**
* @name writeFileTail
* @description Asynchronously writes data to the end of a file.
* @since 1.0.1
* @async
* @param {string|Buffer|URL|FileHandle} filePath
* @param {string} data
* @param {*|null|string=} options
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
export function writeFileTail(
filePath: PathLike,
data: string,
options?: { encoding?: string | null; mode?: string | number; flag?: string | number },
): Promise<true | Error>;
/**
* @name writeJSON
* @description Asynchronously writes data to a file, replacing the file if it already exists.
* @since 0.1.25
* @async
* @param {string|Buffer|URL} filePath
* @param {*} data
* @param {*|null|string=} options
* @param {{sort: boolean, space: number|string}=} configuration
* @returns {Promise<boolean|Error|{name: string, message: string, stack: string}>}
*/
export function writeJSON(
filePath: PathLike,
data: any,
options?: { encoding?: string | null; mode?: string | number; flag?: string | number },
configuration?: { sort?: boolean; space?: number | string },
): Promise<true | Error>;
//#endregion
//#region default
export class HileSystemLocal {
//#region create
/**
* @name createDirectory
* @description Asynchronous create a directory.
* @since 0.0.10
* @async
* @public
* @param {string|Buffer|URL} dirPath
* @param {number|string=} mode
* @param {boolean=} recursive
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public createDirectory(dirPath: PathLike, mode?: number | string, recursive?: boolean): Promise<true | Error>;
/**
* @name createFile
* @description Asynchronous create a file.
* @since 0.0.11
* @async
* @public
* @param {string|Buffer|URL} pathLike
* @param {number|string=} mode
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public createFile(pathLike: PathLike, mode?: number | string): Promise<true | Error>;
//#endregion
//#region dir
/**
* @name dirIsExecutable
* @description Directory can be executed by the calling process
* @since 0.0.5
* @async
* @public
* @param {string} pathToDir
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public dirIsExecutable(pathToDir: PathLike): Promise<true | Error>;
/**
* @name dirIsReadable
* @description Directory is visible to the calling process
* @since 0.0.1
* @async
* @public
* @param {string} pathToDir
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public dirIsReadable(pathToDir: PathLike): Promise<true | Error>;
/**
* @name dirIsVisible
* @description Directory is visible to the calling process
* @since 0.0.5
* @async
* @public
* @param {string} pathToDir
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public dirIsVisible(pathToDir: PathLike): Promise<true | Error>;
/**
* @name dirIsWritable
* @description Directory can be written by the calling process
* @since 0.0.1
* @async
* @public
* @param {string} pathToDir
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public dirIsWritable(pathToDir: PathLike): Promise<true | Error>;
/**
* @name dirIsEmpty
* @description Check If a directory is empty
* @since 0.1.33
* @async
* @public
* @param {string|Buffer|URL} pathToDir
* @param {boolean=} excludeSystemFiles
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public dirIsEmpty(pathToDir: PathLike, excludeSystemFiles: boolean): Promise<boolean | Error>;
//#endregion
//#region file
/**
* @name fileIsExecutable
* @description File can be executed by the calling process
* @since 0.0.5
* @async
* @public
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public fileIsExecutable(pathToFile: PathLike): Promise<true | Error>;
/**
* @name fileIsReadable
* @description File is visible to the calling process
* @since 0.0.1
* @async
* @public
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public fileIsReadable(pathToFile: PathLike): Promise<true | Error>;
/**
* @name fileIsVisible
* @description File is visible to the calling process
* @since 0.0.5
* @async
* @public
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public fileIsVisible(pathToFile: PathLike): Promise<true | Error>;
/**
* @name fileIsWritable
* @description File can be written by the calling process
* @since 0.0.1
* @async
* @public
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public fileIsWritable(pathToFile: PathLike): Promise<true | Error>;
/**
* @name fileTruncate
* @description Truncate a file to a specified length
* @since 0.0.6
* @async
* @public
* @param {string|Buffer|URL} pathToFile
* @param {number=} length
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public fileTruncate(pathToFile: PathLike, length?: number): Promise<true | Error>;
//#endregion
//#region info
/**
* @name hash
* @description Calculate hash.
* @since 0.2.3
* @async
* @public
* @param {string|Buffer|URL} pathToFile
* @param {string} algorithm
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
* @throws {TypeError} If algorithm is not supported.
*/
public hash(pathToFile: PathLike, algorithm: string): Promise<string | Error>;
/**
* @name hashCrc32
* @description CRC32.
* @since 0.2.3
* @async
* @public
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
public hashCrc32(pathToFile: PathLike): Promise<string | Error>;
/**
* @name hashMd5
* @description MD5.
* @since 0.2.3
* @async
* @public
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
public hashMd5(pathToFile: PathLike): Promise<string | Error>;
/**
* @name hashSha1
* @description SHA-1.
* @since 0.2.3
* @async
* @public
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
public hashSha1(pathToFile: PathLike): Promise<string | Error>;
/**
* @name hashSha256
* @description SHA-256.
* @since 0.2.3
* @async
* @public
* @param {string|Buffer|URL} pathToFile
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
public hashSha256(pathToFile: PathLike): Promise<string | Error>;
/**
* @name size
* @description File size in bytes.
* @since 0.2.3
* @async
* @public
* @param {string|Buffer|URL} pathToFile
* @param {boolean=} [asString=false]
* @returns {Promise<number|string|Error|{name: string, message: string, stack?: string}>}
*/
public size(pathToFile: PathLike, asString?: boolean): Promise<number | string | Error>;
//#endregion
//#region list
/**
* @name listContents
* @description Lists files and directories in path
* @since 0.1.32
* @async
* @param {string|Buffer|URL} pathToDir
* @param {boolean} [ignoreJunk=true]
* @returns {Promise<Array.<string>|Error|{name: string, message: string, stack?: string}>}
*/
public listContents(pathToDir: PathLike, ignoreJunk?: boolean): Promise<string[] | Error>;
/**
* @name listDirectories
* @description Lists directories path
* @since 0.1.32
* @async
* @public
* @param {string|Buffer|URL} pathToDir
* @returns {Promise<Array.<string>|Error|{name: string, message: string, stack?: string}>}
*/
public listDirectories(pathToDir: PathLike): Promise<string[] | Error>;
/**
* @name listFiles
* @description Lists files path
* @since 0.1.32
* @async
* @public
* @param {string|Buffer|URL} pathToDir
* @returns {Promise<Array.<string>|Error|{name: string, message: string, stack?: string}>}
*/
public listFiles(pathToDir: PathLike): Promise<string[] | Error>;
//#endregion
//#region move
/**
* @name move
* @description Change the name or location of a file or directory.
* @since 0.1.29
* @async
* @public
* @param {string} pathFrom
* @param {string} pathTo
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public move(pathFrom: PathLike, pathTo: PathLike): Promise<true | Error>;
//#endregion
//#region read
/**
* @name readFileToString
* @description Asynchronously reads the entire contents of a file into string.
* @since 0.1.21
* @async
* @param {string|Buffer|URL} pathLike
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
public readFileToBase64(pathLike: string): Promise<string | Error>;
/**
* @name readFileToBuffer
* @description Asynchronously reads the entire contents of a file into buffer.
* @since 0.1.19
* @async
* @param {string|Buffer|URL} pathLike
* @returns {Promise<Buffer|Error|{name: string, message: string, stack?: string}>}
*/
public readFileToBuffer(pathLike: string): Promise<Buffer | Error>;
/**
* @name readFileToString
* @description Asynchronously reads the entire contents of a file into string.
* @since 0.1.7
* @async
* @param {string|Buffer|URL} pathLike
* @returns {Promise<string|Error|{name: string, message: string, stack?: string}>}
*/
public readFileToString(pathLike: string): Promise<string | Error>;
//#endregion
//#region remove
/**
* @name remove
* @description Removes a file or directory.
* @since 0.1.1
* @async
* @public
* @param {string} pathLike
* @returns {Promise<undefined|Error|{name: string, message: string, stack?: string}>}
*/
public remove(pathLike: string): Promise<undefined | Error>;
//#endregion
//#region path
/**
* @name fileExtension
* @description Get file extension.
* @since 0.1.1
* @public
* @param {string} path
* @returns {string}
*/
public fileExtension(path: string): string;
/**
* @name fileName
* @description Return the file name without extension.
* @since 0.1.1
* @public
* @param {string} path
* @returns {string}
*/
public fileName(path: string): string;
/**
* @name fileNameExt
* @description Return the last portion of a path.
* @since 0.1.1
* @public
* @param {string} path
* @returns {string}
*/
public fileNameExt(path: string): string;
/**
* @name filePath
* @description Return the directory name of a path.
* @since 0.1.1
* @public
* @param {string} path
* @returns {string}
*/
public filePath(path: string): string;
/**
* @name pathFrom
* @description Join all arguments together and normalize the resulting path.
* @since 0.1.3
* @public
* @param {string|Array.<string>} paths
* @param {...string} morePaths
* @returns {string}
*/
public pathFrom(paths: string | string[], ...morePaths: string[]): string;
//#endregion
//#region status
/**
* @name getLinkStatus
* @description Get file status unless `path` refers to a symbolic link, in which case the link itself is stat-ed, not the file that it refers to.
* @url http://man7.org/linux/man-pages/man2/lstat.2.html
* @since 1.1.0
* @async
* @param {string|Buffer|URL} path
* @returns {Promise<Array.<(object|undefined|Error|{name: string, message: string, stack?: string})>>}
*/
public getLinkStatus(path: PathLike): Promise<[Stats?, Error?]>;
/**
* @name getStatus
* @description Get file status.
* @since 0.0.11
* @async
* @public
* @param {string|Buffer|URL} path
* @returns {Promise<[fs.Stats|undefined],[Error|{name: string, message: string, stack?: string}]>}
*/
public getStatus(path: PathLike): Promise<[Stats?, Error?]>;
/**
* @name isDirExists
* @description Get directory status.
* @since 0.0.11
* @async
* @public
* @param {string|Buffer|URL} path
* @returns {Promise<boolean>}
*/
public isDirExists(path: PathLike): Promise<boolean>;
/**
* @name isFileExists
* @description Get file status.
* @since 0.0.11
* @async
* @public
* @param {string|Buffer|URL} path
* @returns {Promise<boolean>}
*/
public isFileExists(path: PathLike): Promise<boolean>;
/**
* @name isPathExists
* @description Get path status.
* @since 0.0.11
* @async
* @public
* @param {string|Buffer|URL} path
* @returns {Promise<boolean>}
*/
public isPathExists(path: PathLike): Promise<boolean>;
//#endregion
//#region write
/**
* @name writeFile
* @description Asynchronously writes data to a file, replacing the file if it already exists.
* @since 0.0.10
* @async
* @public
* @param {string|Buffer|URL|FileHandle} filePath
* @param {*=} data
* @param {*|null|string=} options
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public writeFile(
filePath: PathLike,
data: string,
options?: { encoding?: string | null; mode?: string | number; flag?: string | number },
): Promise<true | Error>;
/**
* @name writeFileTail
* @description Asynchronously writes data to the end of a file.
* @since 1.0.1
* @async
* @public
* @param {string|Buffer|URL|FileHandle} filePath
* @param {*=} data
* @param {*|null|string=} options
* @returns {Promise<boolean|Error|{name: string, message: string, stack?: string}>}
*/
public writeFileTail(
filePath: PathLike,
data: string,
options?: { encoding?: string | null; mode?: string | number; flag?: string | number },
): Promise<true | Error>;
/**
* @name writeJSON
* @description Asynchronously writes data to a file, replacing the file if it already exists.
* @since 0.1.25
* @async
* @public
* @param {string|Buffer|URL} filePath
* @param {*} data
* @param {*|null|string=} options
* @param {{sort: boolean, space: number|string}=} configuration
* @returns {Promise<boolean|Error|{name: string, message: string, stack: string}>}
*/