bare-fs 4.2.2 → 4.3.1

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.
package/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  import EventEmitter, { EventMap } from 'bare-events'
2
2
  import Buffer, { BufferEncoding } from 'bare-buffer'
3
+ import URL from 'bare-url'
3
4
  import { Readable, Writable } from 'bare-stream'
4
5
  import promises from './promises'
5
6
  import constants from './lib/constants'
6
7
 
7
8
  export { promises, constants }
8
9
 
10
+ type Path = string | Buffer | URL
11
+
9
12
  type Flag =
10
13
  | 'a'
11
14
  | 'a+'
@@ -39,15 +42,17 @@ export interface Dir<T extends string | Buffer = string | Buffer>
39
42
  AsyncIterable<Dirent> {
40
43
  readonly path: string
41
44
 
45
+ read(): Promise<Dirent<T> | null>
42
46
  read(cb: Callback<[dirent: Dirent<T> | null]>): void
43
47
  readSync(): Dirent<T> | null
44
48
 
49
+ close(): Promise<void>
45
50
  close(cb: Callback): void
46
51
  closeSync(): void
47
52
  }
48
53
 
49
54
  export class Dir {
50
- constructor(path: string, handle: Buffer, opts?: OpendirOptions)
55
+ private constructor(path: string, handle: ArrayBuffer, opts?: OpendirOptions)
51
56
  }
52
57
 
53
58
  export interface Dirent<T extends string | Buffer = string | Buffer> {
@@ -65,7 +70,7 @@ export interface Dirent<T extends string | Buffer = string | Buffer> {
65
70
  }
66
71
 
67
72
  export class Dirent<T extends string | Buffer = string | Buffer> {
68
- constructor(path: string, name: T, type: number)
73
+ private constructor(path: string, name: T, type: number)
69
74
  }
70
75
 
71
76
  export interface Stats {
@@ -94,7 +99,7 @@ export interface Stats {
94
99
  }
95
100
 
96
101
  export class Stats {
97
- constructor(
102
+ private constructor(
98
103
  dev: number,
99
104
  mode: number,
100
105
  nlink: number,
@@ -112,45 +117,51 @@ export class Stats {
112
117
  )
113
118
  }
114
119
 
115
- export interface FileReadStreamOptions {
120
+ export interface ReadStreamOptions {
121
+ fd?: number
116
122
  flags?: Flag
117
123
  mode?: number
124
+ start?: number
125
+ end?: number
118
126
  }
119
127
 
120
- export interface FileStreamStream extends Readable {
121
- readonly path: string
128
+ export interface ReadStream extends Readable {
129
+ readonly path: string | null
122
130
  readonly fd: number
131
+ readonly flags: Flag
132
+ readonly mode: number
123
133
  }
124
134
 
125
- export class FileReadStream {
126
- constructor(path: string, opts?: FileWriteStreamOptions)
135
+ export class ReadStream {
136
+ private constructor(path: Path | null, opts?: WriteStreamOptions)
127
137
  }
128
138
 
129
139
  export function createReadStream(
130
- path: string,
131
- opts?: FileReadStreamOptions
132
- ): FileReadStream
140
+ path: Path | null,
141
+ opts?: ReadStreamOptions
142
+ ): ReadStream
133
143
 
134
- export interface FileWriteStreamOptions {
144
+ export interface WriteStreamOptions {
145
+ fd?: number
135
146
  flags?: Flag
136
147
  mode?: number
137
148
  }
138
149
 
139
- export interface FileWriteStream extends Writable {
140
- readonly path: string
150
+ export interface WriteStream extends Writable {
151
+ readonly path: string | null
141
152
  readonly fd: number
142
153
  readonly flags: Flag
143
154
  readonly mode: number
144
155
  }
145
156
 
146
- export class FileWriteStream {
147
- constructor(path: string, opts?: FileWriteStreamOptions)
157
+ export class WriteStream {
158
+ private constructor(path: Path | null, opts?: WriteStreamOptions)
148
159
  }
149
160
 
150
161
  export function createWriteStream(
151
- path: string,
152
- opts?: FileWriteStreamOptions
153
- ): FileWriteStream
162
+ path: Path | null,
163
+ opts?: WriteStreamOptions
164
+ ): WriteStream
154
165
 
155
166
  export interface WatcherOptions {
156
167
  persistent?: boolean
@@ -176,14 +187,16 @@ export interface Watcher<T extends string | Buffer = string | Buffer>
176
187
  }
177
188
 
178
189
  export class Watcher {
179
- constructor(path: string | Buffer, opts: WatcherOptions)
190
+ private constructor(path: Path, opts: WatcherOptions)
180
191
  }
181
192
 
182
- export function access(filepath: string, mode: number, cb: Callback): void
193
+ export function access(filepath: Path, mode?: number): Promise<void>
194
+
195
+ export function access(filepath: Path, mode: number, cb: Callback): void
183
196
 
184
- export function access(filepath: string, cb: Callback): void
197
+ export function access(filepath: Path, cb: Callback): void
185
198
 
186
- export function accessSync(filepath: string, mode?: number): void
199
+ export function accessSync(filepath: Path, mode?: number): void
187
200
 
188
201
  export interface AppendFileOptions {
189
202
  encoding?: BufferEncoding
@@ -192,117 +205,143 @@ export interface AppendFileOptions {
192
205
  }
193
206
 
194
207
  export function appendFile(
195
- filepath: string,
208
+ filepath: Path,
209
+ data: string | Buffer | ArrayBufferView,
210
+ opts?: AppendFileOptions
211
+ ): Promise<void>
212
+
213
+ export function appendFile(
214
+ filepath: Path,
215
+ data: string | Buffer | ArrayBufferView,
216
+ encoding: BufferEncoding
217
+ ): Promise<void>
218
+
219
+ export function appendFile(
220
+ filepath: Path,
196
221
  data: string | Buffer | ArrayBufferView,
197
222
  opts: AppendFileOptions,
198
223
  cb: Callback
199
224
  ): void
200
225
 
201
226
  export function appendFile(
202
- filepath: string,
227
+ filepath: Path,
203
228
  data: string | Buffer | ArrayBufferView,
204
229
  encoding: BufferEncoding,
205
230
  cb: Callback
206
231
  ): void
207
232
 
208
233
  export function appendFile(
209
- filepath: string,
234
+ filepath: Path,
210
235
  data: string | Buffer | ArrayBufferView,
211
236
  cb: Callback
212
237
  ): void
213
238
 
214
239
  export function appendFileSync(
215
- filepath: string,
240
+ filepath: Path,
216
241
  data: string | Buffer | ArrayBufferView,
217
242
  opts?: AppendFileOptions
218
243
  ): void
219
244
 
220
245
  export function appendFileSync(
221
- filepath: string,
246
+ filepath: Path,
222
247
  data: string | Buffer | ArrayBufferView,
223
248
  encoding: BufferEncoding
224
249
  ): void
225
250
 
226
- export function chmod(
227
- filepath: string,
228
- mode: string | number,
229
- cb: Callback
230
- ): void
251
+ export function chmod(filepath: Path, mode: string | number): Promise<void>
252
+
253
+ export function chmod(filepath: Path, mode: string | number, cb: Callback): void
231
254
 
232
- export function chmodSync(filepath: string, mode: string | number): void
255
+ export function chmodSync(filepath: Path, mode: string | number): void
233
256
 
234
- export function close(fd: number, cb?: Callback): void
257
+ export function close(fd: number): Promise<void>
258
+
259
+ export function close(fd: number, cb: Callback): void
235
260
 
236
261
  export function closeSync(fd: number): void
237
262
 
238
- export function copyFile(
239
- src: string,
240
- dst: string,
241
- mode: number,
242
- cb: Callback
243
- ): void
263
+ export function copyFile(src: Path, dst: Path, mode?: number): Promise<void>
264
+
265
+ export function copyFile(src: Path, dst: Path, mode: number, cb: Callback): void
266
+
267
+ export function copyFile(src: Path, dst: Path, cb: Callback): void
268
+
269
+ export function copyFileSync(src: Path, dst: Path, mode?: number): void
244
270
 
245
- export function copyFile(src: string, dst: string, cb: Callback): void
271
+ export function exists(filepath: Path): Promise<boolean>
246
272
 
247
- export function copyFileSync(src: string, dst: string, mode?: number): void
273
+ export function exists(filepath: Path, cb: (exists: boolean) => void): void
248
274
 
249
- export function exists(filepath: string, cb: (exists: boolean) => void): void
275
+ export function existsSync(filepath: Path): boolean
250
276
 
251
- export function existsSync(filepath: string): boolean
277
+ export function fchmod(fd: number, mode: string | number): Promise<void>
252
278
 
253
279
  export function fchmod(fd: number, mode: string | number, cb: Callback): void
254
280
 
255
281
  export function fchmodSync(fd: number, mode: string | number): void
256
282
 
283
+ export function fstat(fd: number): Promise<Stats>
284
+
257
285
  export function fstat(fd: number, cb: Callback<[stats: Stats | null]>): void
258
286
 
259
287
  export function fstatSync(fd: number): Stats
260
288
 
289
+ export function ftruncate(fd: number, len?: number): Promise<void>
290
+
261
291
  export function ftruncate(fd: number, len: number, cb: Callback): void
262
292
 
263
293
  export function ftruncate(fd: number, cb: Callback): void
264
294
 
265
- export function ftruncateSync(fd: number, len: number): void
295
+ export function ftruncateSync(fd: number, len?: number): void
266
296
 
267
- export function lstat(
268
- filepath: string,
269
- cb: Callback<[stats: Stats | null]>
270
- ): void
297
+ export function lstat(filepath: Path): Promise<Stats>
271
298
 
272
- export function lstatSync(filepath: string): Stats
299
+ export function lstat(filepath: Path, cb: Callback<[stats: Stats | null]>): void
300
+
301
+ export function lstatSync(filepath: Path): Stats
273
302
 
274
303
  export interface MkdirOptions {
275
304
  mode?: number
276
305
  recursive?: boolean
277
306
  }
278
307
 
279
- export function mkdir(filepath: string, opts: MkdirOptions, cb: Callback): void
308
+ export function mkdir(filepath: Path, opts?: MkdirOptions): Promise<void>
309
+
310
+ export function mkdir(filepath: Path, mode: number): Promise<void>
311
+
312
+ export function mkdir(filepath: Path, opts: MkdirOptions, cb: Callback): void
280
313
 
281
- export function mkdir(filepath: string, mode: number, cb: Callback): void
314
+ export function mkdir(filepath: Path, mode: number, cb: Callback): void
282
315
 
283
- export function mkdir(filepath: string, cb: Callback): void
316
+ export function mkdir(filepath: Path, cb: Callback): void
284
317
 
285
- export function mkdirSync(filepath: string, opts?: MkdirOptions): void
318
+ export function mkdirSync(filepath: Path, opts?: MkdirOptions): void
286
319
 
287
- export function mkdirSync(filepath: string, mode: number): void
320
+ export function mkdirSync(filepath: Path, mode: number): void
288
321
 
289
322
  export function open(
290
- filepath: string,
323
+ filepath: Path,
324
+ flags?: Flag | number,
325
+ mode?: string | number
326
+ ): Promise<number>
327
+
328
+ export function open(
329
+ filepath: Path,
291
330
  flags: Flag | number,
292
331
  mode: string | number,
293
332
  cb: Callback<[fd: number]>
294
333
  ): void
295
334
 
296
335
  export function open(
297
- filepath: string,
336
+ filepath: Path,
298
337
  flags: Flag | number,
299
338
  cb: Callback<[fd: number]>
300
339
  ): void
301
340
 
302
- export function open(filepath: string, cb: Callback<[fd: number]>): void
341
+ export function open(filepath: Path, cb: Callback<[fd: number]>): void
303
342
 
304
343
  export function openSync(
305
- filepath: string,
344
+ filepath: Path,
306
345
  flags?: Flag | number,
307
346
  mode?: string | number
308
347
  ): number
@@ -313,71 +352,108 @@ export interface OpendirOptions {
313
352
  }
314
353
 
315
354
  export function opendir(
316
- filepath: string,
355
+ filepath: Path,
356
+ opts: OpendirOptions & { encoding?: BufferEncoding }
357
+ ): Promise<Dir<string>>
358
+
359
+ export function opendir(
360
+ filepath: Path,
361
+ opts: OpendirOptions & { encoding: 'buffer' }
362
+ ): Promise<Dir<Buffer>>
363
+
364
+ export function opendir(filepath: Path, opts: OpendirOptions): Promise<Dir>
365
+
366
+ export function opendir(
367
+ filepath: Path,
368
+ encoding: BufferEncoding
369
+ ): Promise<Dir<string>>
370
+
371
+ export function opendir(
372
+ filepath: Path,
373
+ encoding: 'buffer'
374
+ ): Promise<Dir<Buffer>>
375
+
376
+ export function opendir(
377
+ filepath: Path,
378
+ encoding: BufferEncoding | 'buffer'
379
+ ): Promise<Dir>
380
+
381
+ export function opendir(filepath: Path): Promise<Dir<string>>
382
+
383
+ export function opendir(
384
+ filepath: Path,
317
385
  opts: OpendirOptions & { encoding?: BufferEncoding },
318
386
  cb: Callback<[dir: Dir<string> | null]>
319
387
  ): void
320
388
 
321
389
  export function opendir(
322
- filepath: string,
390
+ filepath: Path,
323
391
  opts: OpendirOptions & { encoding: 'buffer' },
324
392
  cb: Callback<[dir: Dir<Buffer> | null]>
325
393
  ): void
326
394
 
327
395
  export function opendir(
328
- filepath: string,
396
+ filepath: Path,
329
397
  opts: OpendirOptions,
330
398
  cb: Callback<[dir: Dir | null]>
331
399
  ): void
332
400
 
333
401
  export function opendir(
334
- filepath: string,
402
+ filepath: Path,
335
403
  encoding: BufferEncoding,
336
404
  cb: Callback<[dir: Dir<string> | null]>
337
405
  ): void
338
406
 
339
407
  export function opendir(
340
- filepath: string,
408
+ filepath: Path,
341
409
  encoding: 'buffer',
342
410
  cb: Callback<[dir: Dir<Buffer> | null]>
343
411
  ): void
344
412
 
345
413
  export function opendir(
346
- filepath: string,
414
+ filepath: Path,
347
415
  encoding: BufferEncoding | 'buffer',
348
416
  cb: Callback<[dir: Dir | null]>
349
417
  ): void
350
418
 
351
419
  export function opendir(
352
- filepath: string,
420
+ filepath: Path,
353
421
  cb: Callback<[dir: Dir<string> | null]>
354
422
  ): void
355
423
 
356
424
  export function opendirSync(
357
- filepath: string,
425
+ filepath: Path,
358
426
  opts: OpendirOptions & { encoding?: BufferEncoding }
359
427
  ): Dir<string>
360
428
 
361
429
  export function opendirSync(
362
- filepath: string,
430
+ filepath: Path,
363
431
  opts: OpendirOptions & { encoding: 'buffer' }
364
432
  ): Dir<Buffer>
365
433
 
366
- export function opendirSync(filepath: string, opts: OpendirOptions): Dir
434
+ export function opendirSync(filepath: Path, opts: OpendirOptions): Dir
367
435
 
368
436
  export function opendirSync(
369
- filepath: string,
437
+ filepath: Path,
370
438
  encoding: BufferEncoding
371
439
  ): Dir<string>
372
440
 
373
- export function opendirSync(filepath: string, encoding: 'buffer'): Dir<Buffer>
441
+ export function opendirSync(filepath: Path, encoding: 'buffer'): Dir<Buffer>
374
442
 
375
443
  export function opendirSync(
376
- filepath: string,
444
+ filepath: Path,
377
445
  encoding: BufferEncoding | 'buffer'
378
446
  ): Dir
379
447
 
380
- export function opendirSync(filepath: string): Dir<string>
448
+ export function opendirSync(filepath: Path): Dir<string>
449
+
450
+ export function read(
451
+ fd: number,
452
+ buffer: Buffer | ArrayBufferView,
453
+ offset?: number,
454
+ len?: number,
455
+ pos?: number
456
+ ): Promise<number>
381
457
 
382
458
  export function read(
383
459
  fd: number,
@@ -423,282 +499,398 @@ export interface ReadFileOptions {
423
499
  }
424
500
 
425
501
  export function readFile(
426
- filepath: string,
502
+ filepath: Path,
503
+ opts: ReadFileOptions & { encoding: BufferEncoding }
504
+ ): Promise<string>
505
+
506
+ export function readFile(
507
+ filepath: Path,
508
+ opts: ReadFileOptions & { encoding?: 'buffer' }
509
+ ): Promise<Buffer>
510
+
511
+ export function readFile(
512
+ filepath: Path,
513
+ opts: ReadFileOptions
514
+ ): Promise<string | Buffer>
515
+
516
+ export function readFile(
517
+ filepath: Path,
518
+ encoding: BufferEncoding
519
+ ): Promise<string>
520
+
521
+ export function readFile(filepath: Path, encoding: 'buffer'): Promise<Buffer>
522
+
523
+ export function readFile(
524
+ filepath: Path,
525
+ encoding?: BufferEncoding | 'buffer'
526
+ ): Promise<string | Buffer>
527
+
528
+ export function readFile(filepath: Path): Promise<Buffer>
529
+
530
+ export function readFile(
531
+ filepath: Path,
427
532
  opts: ReadFileOptions & { encoding: BufferEncoding },
428
533
  cb: Callback<[buffer?: string]>
429
534
  ): void
430
535
 
431
536
  export function readFile(
432
- filepath: string,
537
+ filepath: Path,
433
538
  opts: ReadFileOptions & { encoding?: 'buffer' },
434
539
  cb: Callback<[buffer?: Buffer]>
435
540
  ): void
436
541
 
437
542
  export function readFile(
438
- filepath: string,
543
+ filepath: Path,
439
544
  opts: ReadFileOptions,
440
545
  cb: Callback<[buffer?: string | Buffer]>
441
546
  ): void
442
547
 
443
548
  export function readFile(
444
- filepath: string,
549
+ filepath: Path,
445
550
  encoding: BufferEncoding,
446
551
  cb: Callback<[buffer?: string]>
447
552
  ): void
448
553
 
449
554
  export function readFile(
450
- filepath: string,
555
+ filepath: Path,
451
556
  encoding: 'buffer',
452
557
  cb: Callback<[buffer?: Buffer]>
453
558
  ): void
454
559
 
455
560
  export function readFile(
456
- filepath: string,
561
+ filepath: Path,
457
562
  encoding: BufferEncoding | 'buffer',
458
563
  cb: Callback<[buffer?: string | Buffer]>
459
564
  ): void
460
565
 
461
- export function readFile(
462
- filepath: string,
463
- cb: Callback<[buffer?: Buffer]>
464
- ): void
566
+ export function readFile(filepath: Path, cb: Callback<[buffer?: Buffer]>): void
465
567
 
466
568
  export function readFileSync(
467
- filepath: string,
569
+ filepath: Path,
468
570
  opts: ReadFileOptions & { encoding: BufferEncoding }
469
571
  ): string
470
572
 
471
573
  export function readFileSync(
472
- filepath: string,
574
+ filepath: Path,
473
575
  opts: ReadFileOptions & { encoding?: 'buffer' }
474
576
  ): Buffer
475
577
 
476
578
  export function readFileSync(
477
- filepath: string,
579
+ filepath: Path,
478
580
  opts: ReadFileOptions
479
581
  ): string | Buffer
480
582
 
481
- export function readFileSync(filepath: string, encoding: BufferEncoding): string
583
+ export function readFileSync(filepath: Path, encoding: BufferEncoding): string
482
584
 
483
- export function readFileSync(filepath: string, encoding: 'buffer'): Buffer
585
+ export function readFileSync(filepath: Path, encoding: 'buffer'): Buffer
484
586
 
485
587
  export function readFileSync(
486
- filepath: string,
588
+ filepath: Path,
487
589
  encoding?: BufferEncoding | 'buffer'
488
590
  ): string | Buffer
489
591
 
490
- export function readFileSync(filepath: string): Buffer
592
+ export function readFileSync(filepath: Path): Buffer
491
593
 
492
594
  export interface ReaddirOptions extends OpendirOptions {
493
595
  withFileTypes?: boolean
494
596
  }
597
+ export function readdir(
598
+ filepath: Path,
599
+ opts: ReaddirOptions & { encoding?: BufferEncoding }
600
+ ): Promise<Dir<string>[] | string[]>
601
+
602
+ export function readdir(
603
+ filepath: Path,
604
+ opts: ReaddirOptions & { encoding?: BufferEncoding; withFileTypes: true }
605
+ ): Promise<Dir<string>[]>
606
+
607
+ export function readdir(
608
+ filepath: Path,
609
+ opts: ReaddirOptions & { encoding?: BufferEncoding; withFileTypes?: false }
610
+ ): Promise<string[]>
611
+
612
+ export function readdir(
613
+ filepath: Path,
614
+ opts: ReaddirOptions & { encoding: 'buffer' }
615
+ ): Promise<Dir<Buffer>[] | Buffer[]>
616
+
617
+ export function readdir(
618
+ filepath: Path,
619
+ opts: ReaddirOptions & { encoding: 'buffer'; withFileTypes: true }
620
+ ): Promise<Dir<Buffer>[]>
621
+
622
+ export function readdir(
623
+ filepath: Path,
624
+ opts: ReaddirOptions & { encoding: 'buffer'; withFileTypes?: false }
625
+ ): Promise<Buffer[]>
626
+
627
+ export function readdir(
628
+ filepath: Path,
629
+ opts: ReaddirOptions & { withFileTypes: true }
630
+ ): Promise<Dir<string | Buffer>[]>
631
+
632
+ export function readdir(
633
+ filepath: Path,
634
+ opts: ReaddirOptions & { withFileTypes?: false }
635
+ ): Promise<string[] | Buffer[]>
636
+
637
+ export function readdir(
638
+ filepath: Path,
639
+ opts: ReaddirOptions
640
+ ): Promise<Dir[] | string[] | Buffer[]>
641
+
642
+ export function readdir(
643
+ filepath: Path,
644
+ encoding: BufferEncoding
645
+ ): Promise<string[]>
646
+
647
+ export function readdir(filepath: Path, encoding: 'buffer'): Promise<Buffer[]>
648
+
649
+ export function readdir(
650
+ filepath: Path,
651
+ encoding: BufferEncoding | 'buffer'
652
+ ): Promise<string[] | Buffer[]>
653
+
654
+ export function readdir(filepath: Path): Promise<string[]>
495
655
 
496
656
  export function readdir(
497
- filepath: string,
657
+ filepath: Path,
498
658
  opts: ReaddirOptions & { encoding?: BufferEncoding },
499
659
  cb: Callback<[entries: Dir<string>[] | string[] | null]>
500
660
  ): void
501
661
 
502
662
  export function readdir(
503
- filepath: string,
663
+ filepath: Path,
504
664
  opts: ReaddirOptions & { encoding?: BufferEncoding; withFileTypes: true },
505
665
  cb: Callback<[entries: Dir<string>[] | null]>
506
666
  ): void
507
667
 
508
668
  export function readdir(
509
- filepath: string,
669
+ filepath: Path,
510
670
  opts: ReaddirOptions & { encoding?: BufferEncoding; withFileTypes?: false },
511
671
  cb: Callback<[entries: string[] | null]>
512
672
  ): void
513
673
 
514
674
  export function readdir(
515
- filepath: string,
675
+ filepath: Path,
516
676
  opts: ReaddirOptions & { encoding: 'buffer' },
517
677
  cb: Callback<[entries: Dir<Buffer>[] | Buffer[] | null]>
518
678
  ): void
519
679
 
520
680
  export function readdir(
521
- filepath: string,
681
+ filepath: Path,
522
682
  opts: ReaddirOptions & { encoding: 'buffer'; withFileTypes: true },
523
683
  cb: Callback<[entries: Dir<Buffer>[] | null]>
524
684
  ): void
525
685
 
526
686
  export function readdir(
527
- filepath: string,
687
+ filepath: Path,
528
688
  opts: ReaddirOptions & { encoding: 'buffer'; withFileTypes?: false },
529
689
  cb: Callback<[entries: Buffer[] | null]>
530
690
  ): void
531
691
 
532
692
  export function readdir(
533
- filepath: string,
693
+ filepath: Path,
534
694
  opts: ReaddirOptions & { withFileTypes: true },
535
695
  cb: Callback<[entries: Dir<string | Buffer>[] | null]>
536
696
  ): void
537
697
 
538
698
  export function readdir(
539
- filepath: string,
699
+ filepath: Path,
540
700
  opts: ReaddirOptions & { withFileTypes?: false },
541
701
  cb: Callback<[entries: string[] | Buffer[] | null]>
542
702
  ): void
543
703
 
544
704
  export function readdir(
545
- filepath: string,
705
+ filepath: Path,
546
706
  opts: ReaddirOptions,
547
707
  cb: Callback<[entries: Dir[] | string[] | Buffer[] | null]>
548
708
  ): void
549
709
 
550
710
  export function readdir(
551
- filepath: string,
711
+ filepath: Path,
552
712
  encoding: BufferEncoding,
553
713
  cb: Callback<[entries: string[] | null]>
554
714
  ): void
555
715
 
556
716
  export function readdir(
557
- filepath: string,
717
+ filepath: Path,
558
718
  encoding: 'buffer',
559
719
  cb: Callback<[entries: Buffer[] | null]>
560
720
  ): void
561
721
 
562
722
  export function readdir(
563
- filepath: string,
723
+ filepath: Path,
564
724
  encoding: BufferEncoding | 'buffer',
565
725
  cb: Callback<[entries: string[] | Buffer[] | null]>
566
726
  ): void
567
727
 
568
728
  export function readdir(
569
- filepath: string,
729
+ filepath: Path,
570
730
  cb: Callback<[entries: string[] | null]>
571
731
  ): void
572
732
 
573
733
  export function readdirSync(
574
- filepath: string,
734
+ filepath: Path,
575
735
  opts: ReaddirOptions & { encoding?: BufferEncoding }
576
736
  ): Dir<string>[] | string[]
577
737
 
578
738
  export function readdirSync(
579
- filepath: string,
739
+ filepath: Path,
580
740
  opts: ReaddirOptions & { encoding?: BufferEncoding; withFileTypes: true }
581
741
  ): Dir<string>[]
582
742
 
583
743
  export function readdirSync(
584
- filepath: string,
744
+ filepath: Path,
585
745
  opts: ReaddirOptions & { encoding?: BufferEncoding; withFileTypes?: false }
586
746
  ): string[]
587
747
 
588
748
  export function readdirSync(
589
- filepath: string,
749
+ filepath: Path,
590
750
  opts: ReaddirOptions & { encoding: 'buffer' }
591
751
  ): Dir<Buffer>[] | Buffer[]
592
752
 
593
753
  export function readdirSync(
594
- filepath: string,
754
+ filepath: Path,
595
755
  opts: ReaddirOptions & { encoding: 'buffer'; withFileTypes: true }
596
756
  ): Dir<Buffer>[]
597
757
 
598
758
  export function readdirSync(
599
- filepath: string,
759
+ filepath: Path,
600
760
  opts: ReaddirOptions & { encoding: 'buffer'; withFileTypes?: false }
601
761
  ): Buffer[]
602
762
 
603
763
  export function readdirSync(
604
- filepath: string,
764
+ filepath: Path,
605
765
  opts: ReaddirOptions & { withFileTypes: true }
606
766
  ): Dir<string | Buffer>[]
607
767
 
608
768
  export function readdirSync(
609
- filepath: string,
769
+ filepath: Path,
610
770
  opts: ReaddirOptions & { withFileTypes?: false }
611
771
  ): string[] | Buffer[]
612
772
 
613
773
  export function readdirSync(
614
- filepath: string,
774
+ filepath: Path,
615
775
  opts: ReaddirOptions
616
776
  ): Dir[] | string[] | Buffer[]
617
777
 
618
- export function readdirSync(
619
- filepath: string,
620
- encoding: BufferEncoding
621
- ): string[]
778
+ export function readdirSync(filepath: Path, encoding: BufferEncoding): string[]
622
779
 
623
- export function readdirSync(filepath: string, encoding: 'buffer'): Buffer[]
780
+ export function readdirSync(filepath: Path, encoding: 'buffer'): Buffer[]
624
781
 
625
782
  export function readdirSync(
626
- filepath: string,
783
+ filepath: Path,
627
784
  encoding: BufferEncoding | 'buffer'
628
785
  ): string[] | Buffer[]
629
786
 
630
- export function readdirSync(filepath: string): string[]
787
+ export function readdirSync(filepath: Path): string[]
631
788
 
632
789
  export interface ReadlinkOptions {
633
790
  encoding?: BufferEncoding | 'buffer'
634
791
  }
635
792
 
636
793
  export function readlink(
637
- filepath: string,
794
+ filepath: Path,
795
+ opts: ReadlinkOptions & { encoding?: BufferEncoding }
796
+ ): Promise<string>
797
+
798
+ export function readlink(
799
+ filepath: Path,
800
+ opts: ReadlinkOptions & { encoding: 'buffer' }
801
+ ): Promise<Buffer>
802
+
803
+ export function readlink(
804
+ filepath: Path,
805
+ opts: ReadlinkOptions
806
+ ): Promise<string | Buffer>
807
+
808
+ export function readlink(
809
+ filepath: Path,
810
+ encoding: BufferEncoding
811
+ ): Promise<string>
812
+
813
+ export function readlink(filepath: Path, encoding: 'buffer'): Promise<Buffer>
814
+
815
+ export function readlink(
816
+ filepath: Path,
817
+ encoding: BufferEncoding | 'buffer'
818
+ ): Promise<string | Buffer>
819
+
820
+ export function readlink(filepath: Path): Promise<string>
821
+
822
+ export function readlink(
823
+ filepath: Path,
638
824
  opts: ReadlinkOptions & { encoding?: BufferEncoding },
639
825
  cb: Callback<[link: string | null]>
640
826
  ): void
641
827
 
642
828
  export function readlink(
643
- filepath: string,
829
+ filepath: Path,
644
830
  opts: ReadlinkOptions & { encoding: 'buffer' },
645
831
  cb: Callback<[link: Buffer | null]>
646
832
  ): void
647
833
 
648
834
  export function readlink(
649
- filepath: string,
835
+ filepath: Path,
650
836
  opts: ReadlinkOptions,
651
837
  cb: Callback<[link: string | Buffer | null]>
652
838
  ): void
653
839
 
654
840
  export function readlink(
655
- filepath: string,
841
+ filepath: Path,
656
842
  encoding: BufferEncoding,
657
843
  cb: Callback<[link: string | null]>
658
844
  ): void
659
845
 
660
846
  export function readlink(
661
- filepath: string,
847
+ filepath: Path,
662
848
  encoding: 'buffer',
663
849
  cb: Callback<[link: Buffer | null]>
664
850
  ): void
665
851
 
666
852
  export function readlink(
667
- filepath: string,
853
+ filepath: Path,
668
854
  encoding: BufferEncoding | 'buffer',
669
855
  cb: Callback<[link: string | Buffer | null]>
670
856
  ): void
671
857
 
672
858
  export function readlink(
673
- filepath: string,
859
+ filepath: Path,
674
860
  cb: Callback<[link: string | null]>
675
861
  ): void
676
862
 
677
863
  export function readlinkSync(
678
- filepath: string,
864
+ filepath: Path,
679
865
  opts: ReadlinkOptions & { encoding?: BufferEncoding }
680
866
  ): string
681
867
 
682
868
  export function readlinkSync(
683
- filepath: string,
869
+ filepath: Path,
684
870
  opts: ReadlinkOptions & { encoding: 'buffer' }
685
871
  ): Buffer
686
872
 
687
873
  export function readlinkSync(
688
- filepath: string,
874
+ filepath: Path,
689
875
  opts: ReadlinkOptions
690
876
  ): string | Buffer
691
877
 
692
- export function readlinkSync(filepath: string, encoding: BufferEncoding): string
878
+ export function readlinkSync(filepath: Path, encoding: BufferEncoding): string
693
879
 
694
- export function readlinkSync(filepath: string, encoding: 'buffer'): Buffer
880
+ export function readlinkSync(filepath: Path, encoding: 'buffer'): Buffer
695
881
 
696
882
  export function readlinkSync(
697
- filepath: string,
883
+ filepath: Path,
698
884
  encoding: BufferEncoding | 'buffer'
699
885
  ): string | Buffer
700
886
 
701
- export function readlinkSync(filepath: string): string
887
+ export function readlinkSync(filepath: Path): string
888
+
889
+ export function readv(
890
+ fd: number,
891
+ buffers: ArrayBufferView[],
892
+ position?: number
893
+ ): Promise<number>
702
894
 
703
895
  export function readv(
704
896
  fd: number,
@@ -713,76 +905,113 @@ export function readv(
713
905
  cb: Callback<[len: number]>
714
906
  ): void
715
907
 
908
+ export function readvSync(
909
+ fd: number,
910
+ buffers: ArrayBufferView[],
911
+ position?: number
912
+ ): number
913
+
716
914
  export interface RealpathOptions {
717
915
  encoding?: BufferEncoding | 'buffer'
718
916
  }
719
917
 
720
918
  export function realpath(
721
- filepath: string,
919
+ filepath: Path,
920
+ opts: RealpathOptions & { encoding?: BufferEncoding }
921
+ ): Promise<string>
922
+
923
+ export function realpath(
924
+ filepath: Path,
925
+ opts: RealpathOptions & { encoding: 'buffer' }
926
+ ): Promise<Buffer>
927
+
928
+ export function realpath(
929
+ filepath: Path,
930
+ opts: RealpathOptions
931
+ ): Promise<string | Buffer>
932
+
933
+ export function realpath(
934
+ filepath: Path,
935
+ encoding: BufferEncoding
936
+ ): Promise<string>
937
+
938
+ export function realpath(filepath: Path, encoding: 'buffer'): Promise<Buffer>
939
+
940
+ export function realpath(
941
+ filepath: Path,
942
+ encoding: BufferEncoding | 'buffer'
943
+ ): Promise<string | Buffer>
944
+
945
+ export function realpath(filepath: Path): Promise<string>
946
+
947
+ export function realpath(
948
+ filepath: Path,
722
949
  opts: RealpathOptions & { encoding?: BufferEncoding },
723
950
  cb: Callback<[path: string | null]>
724
951
  ): void
725
952
 
726
953
  export function realpath(
727
- filepath: string,
954
+ filepath: Path,
728
955
  opts: RealpathOptions & { encoding: 'buffer' },
729
956
  cb: Callback<[path: Buffer | null]>
730
957
  ): void
731
958
 
732
959
  export function realpath(
733
- filepath: string,
960
+ filepath: Path,
734
961
  opts: RealpathOptions,
735
962
  cb: Callback<[path: string | Buffer | null]>
736
963
  ): void
737
964
 
738
965
  export function realpath(
739
- filepath: string,
966
+ filepath: Path,
740
967
  encoding: BufferEncoding,
741
968
  cb: Callback<[path: string | null]>
742
969
  ): void
743
970
 
744
971
  export function realpath(
745
- filepath: string,
972
+ filepath: Path,
746
973
  encoding: 'buffer',
747
974
  cb: Callback<[path: Buffer | null]>
748
975
  ): void
749
976
 
750
977
  export function realpath(
751
- filepath: string,
978
+ filepath: Path,
752
979
  encoding: BufferEncoding | 'buffer',
753
980
  cb: Callback<[path: string | Buffer | null]>
754
981
  ): void
755
982
 
756
983
  export function realpath(
757
- filepath: string,
984
+ filepath: Path,
758
985
  cb: Callback<[path: string | null]>
759
986
  ): void
760
987
 
761
988
  export function realpathSync(
762
- filepath: string,
989
+ filepath: Path,
763
990
  opts: RealpathOptions & { encoding?: BufferEncoding }
764
991
  ): string
765
992
 
766
993
  export function realpathSync(
767
- filepath: string,
994
+ filepath: Path,
768
995
  opts: RealpathOptions & { encoding: 'buffer' }
769
996
  ): Buffer
770
997
 
771
998
  export function realpathSync(
772
- filepath: string,
999
+ filepath: Path,
773
1000
  opts: RealpathOptions
774
1001
  ): string | Buffer
775
1002
 
776
- export function realpathSync(filepath: string, encoding: BufferEncoding): string
1003
+ export function realpathSync(filepath: Path, encoding: BufferEncoding): string
777
1004
 
778
- export function realpathSync(filepath: string, encoding: 'buffer'): Buffer
1005
+ export function realpathSync(filepath: Path, encoding: 'buffer'): Buffer
779
1006
 
780
1007
  export function realpathSync(
781
- filepath: string,
1008
+ filepath: Path,
782
1009
  encoding: BufferEncoding | 'buffer'
783
1010
  ): string | Buffer
784
1011
 
785
- export function realpathSync(filepath: string): string
1012
+ export function realpathSync(filepath: Path): string
1013
+
1014
+ export function rename(src: string, dst: string): Promise<void>
786
1015
 
787
1016
  export function rename(src: string, dst: string, cb: Callback): void
788
1017
 
@@ -793,83 +1022,100 @@ export interface RmOptions {
793
1022
  recursive?: boolean
794
1023
  }
795
1024
 
796
- export function rm(filepath: string, opts: RmOptions, cb: Callback): void
1025
+ export function rm(filepath: Path, opts?: RmOptions): Promise<void>
797
1026
 
798
- export function rm(filepath: string, cb: Callback): void
1027
+ export function rm(filepath: Path, opts: RmOptions, cb: Callback): void
799
1028
 
800
- export function rmSync(filepath: string, opts?: RmOptions): void
1029
+ export function rm(filepath: Path, cb: Callback): void
801
1030
 
802
- export function rmdir(filepath: string, cb: Callback): void
1031
+ export function rmSync(filepath: Path, opts?: RmOptions): void
803
1032
 
804
- export function rmdirSync(filepath: string): void
1033
+ export function rmdir(filepath: Path, cb: Callback): void
805
1034
 
806
- export function stat(
807
- filepath: string,
808
- cb: Callback<[stats: Stats | null]>
809
- ): void
1035
+ export function rmdirSync(filepath: Path): void
1036
+
1037
+ export function stat(filepath: Path): Promise<Stats>
810
1038
 
811
- export function statSync(filepath: string): Stats
1039
+ export function stat(filepath: Path, cb: Callback<[stats: Stats | null]>): void
1040
+
1041
+ export function statSync(filepath: Path): Stats
812
1042
 
813
1043
  export function symlink(
814
- target: string,
815
- filepath: string,
1044
+ target: Path,
1045
+ filepath: Path,
1046
+ type?: string | number
1047
+ ): Promise<void>
1048
+
1049
+ export function symlink(
1050
+ target: Path,
1051
+ filepath: Path,
816
1052
  type: string | number,
817
1053
  cb: Callback
818
1054
  ): void
819
1055
 
820
- export function symlink(target: string, filepath: string, cb: Callback): void
1056
+ export function symlink(target: string, filepath: Path, cb: Callback): void
821
1057
 
822
1058
  export function symlinkSync(
823
1059
  target: string,
824
- filepath: string,
1060
+ filepath: Path,
825
1061
  type?: string | number
826
1062
  ): void
827
1063
 
828
- export function unlink(filepath: string, cb: Callback): void
1064
+ export function unlink(filepath: Path): Promise<void>
1065
+
1066
+ export function unlink(filepath: Path, cb: Callback): void
829
1067
 
830
- export function unlinkSync(filepath: string): void
1068
+ export function unlinkSync(filepath: Path): void
831
1069
 
832
1070
  export function watch(
833
- filepath: string,
1071
+ filepath: Path,
834
1072
  opts: WatcherOptions & { encoding?: BufferEncoding },
835
1073
  cb: (eventType: WatcherEventType, filename: string) => void
836
1074
  ): Watcher<string>
837
1075
 
838
1076
  export function watch(
839
- filepath: string,
1077
+ filepath: Path,
840
1078
  opts: WatcherOptions & { encoding: 'buffer' },
841
1079
  cb: (eventType: WatcherEventType, filename: Buffer) => void
842
1080
  ): Watcher<Buffer>
843
1081
 
844
1082
  export function watch(
845
- filepath: string,
1083
+ filepath: Path,
846
1084
  opts: WatcherOptions,
847
1085
  cb: (eventType: WatcherEventType, filename: string | Buffer) => void
848
1086
  ): Watcher
849
1087
 
850
1088
  export function watch(
851
- filepath: string,
1089
+ filepath: Path,
852
1090
  encoding: BufferEncoding,
853
1091
  cb: (evenType: WatcherEventType, filename: string) => void
854
1092
  ): Watcher<string>
855
1093
 
856
1094
  export function watch(
857
- filepath: string,
1095
+ filepath: Path,
858
1096
  encoding: 'buffer',
859
1097
  cb: (evenType: WatcherEventType, filename: Buffer) => void
860
1098
  ): Watcher<Buffer>
861
1099
 
862
1100
  export function watch(
863
- filepath: string,
1101
+ filepath: Path,
864
1102
  encoding: BufferEncoding | 'buffer',
865
1103
  cb: (evenType: WatcherEventType, filename: string | Buffer) => void
866
1104
  ): Watcher
867
1105
 
868
1106
  export function watch(
869
- filepath: string,
1107
+ filepath: Path,
870
1108
  cb: (eventType: WatcherEventType, filename: string) => void
871
1109
  ): Watcher<string>
872
1110
 
1111
+ export function write(
1112
+ fd: number,
1113
+ data: string | Buffer | ArrayBufferView,
1114
+ offset?: number,
1115
+ len?: number,
1116
+ pos?: number
1117
+ ): Promise<number>
1118
+
873
1119
  export function write(
874
1120
  fd: number,
875
1121
  data: Buffer | ArrayBufferView,
@@ -927,7 +1173,7 @@ export function writeSync(
927
1173
  offset?: number,
928
1174
  len?: number,
929
1175
  pos?: number
930
- ): void
1176
+ ): number
931
1177
 
932
1178
  export interface WriteFileOptions {
933
1179
  encoding?: BufferEncoding
@@ -936,37 +1182,55 @@ export interface WriteFileOptions {
936
1182
  }
937
1183
 
938
1184
  export function writeFile(
939
- filepath: string,
1185
+ filepath: Path,
1186
+ data: string | Buffer | ArrayBufferView,
1187
+ opts?: WriteFileOptions
1188
+ ): Promise<void>
1189
+
1190
+ export function writeFile(
1191
+ filepath: Path,
1192
+ data: string | Buffer | ArrayBufferView,
1193
+ encoding: BufferEncoding
1194
+ ): Promise<void>
1195
+
1196
+ export function writeFile(
1197
+ filepath: Path,
940
1198
  data: string | Buffer | ArrayBufferView,
941
1199
  opts: WriteFileOptions,
942
1200
  cb: Callback
943
1201
  ): void
944
1202
 
945
1203
  export function writeFile(
946
- filepath: string,
1204
+ filepath: Path,
947
1205
  data: string | Buffer | ArrayBufferView,
948
1206
  encoding: BufferEncoding,
949
1207
  cb: Callback
950
1208
  ): void
951
1209
 
952
1210
  export function writeFile(
953
- filepath: string,
1211
+ filepath: Path,
954
1212
  data: string | Buffer | ArrayBufferView,
955
1213
  cb: Callback
956
1214
  ): void
957
1215
 
958
1216
  export function writeFileSync(
959
- filepath: string,
1217
+ filepath: Path,
960
1218
  data: string | Buffer | ArrayBufferView,
961
1219
  opts?: WriteFileOptions
962
1220
  ): void
963
1221
 
964
1222
  export function writeFileSync(
965
- filepath: string,
1223
+ filepath: Path,
966
1224
  data: string | Buffer | ArrayBufferView,
967
1225
  encoding: BufferEncoding
968
1226
  ): void
969
1227
 
1228
+ export function writev(
1229
+ fd: number,
1230
+ buffers: ArrayBufferView[],
1231
+ pos?: number
1232
+ ): Promise<number>
1233
+
970
1234
  export function writev(
971
1235
  fd: number,
972
1236
  buffers: ArrayBufferView[],
@@ -979,3 +1243,9 @@ export function writev(
979
1243
  buffers: ArrayBufferView[],
980
1244
  cb: Callback<[len: number]>
981
1245
  ): void
1246
+
1247
+ export function writevSync(
1248
+ fd: number,
1249
+ buffers: ArrayBufferView[],
1250
+ pos?: number
1251
+ ): number