@zenfs/core 1.0.9 → 1.0.11

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.
Files changed (71) hide show
  1. package/dist/backends/backend.d.ts +4 -8
  2. package/dist/backends/backend.js +7 -11
  3. package/dist/backends/fetch.d.ts +2 -4
  4. package/dist/backends/fetch.js +1 -3
  5. package/dist/backends/memory.d.ts +1 -1
  6. package/dist/backends/overlay.d.ts +9 -5
  7. package/dist/backends/overlay.js +128 -55
  8. package/dist/backends/port/fs.d.ts +12 -17
  9. package/dist/backends/port/fs.js +5 -8
  10. package/dist/backends/port/rpc.d.ts +1 -1
  11. package/dist/backends/store/fs.d.ts +8 -10
  12. package/dist/backends/store/fs.js +30 -49
  13. package/dist/backends/store/simple.d.ts +1 -1
  14. package/dist/backends/store/simple.js +1 -1
  15. package/dist/backends/store/store.d.ts +7 -13
  16. package/dist/config.d.ts +5 -5
  17. package/dist/config.js +26 -26
  18. package/dist/emulation/async.d.ts +21 -176
  19. package/dist/emulation/async.js +17 -111
  20. package/dist/emulation/dir.d.ts +0 -1
  21. package/dist/emulation/path.d.ts +0 -4
  22. package/dist/emulation/path.js +4 -8
  23. package/dist/emulation/promises.d.ts +31 -121
  24. package/dist/emulation/promises.js +30 -97
  25. package/dist/emulation/shared.d.ts +7 -3
  26. package/dist/emulation/shared.js +8 -5
  27. package/dist/emulation/streams.d.ts +0 -3
  28. package/dist/emulation/sync.d.ts +25 -178
  29. package/dist/emulation/sync.js +36 -129
  30. package/dist/emulation/watchers.d.ts +0 -4
  31. package/dist/error.d.ts +11 -11
  32. package/dist/error.js +8 -10
  33. package/dist/file.d.ts +50 -171
  34. package/dist/file.js +33 -115
  35. package/dist/filesystem.d.ts +10 -62
  36. package/dist/filesystem.js +5 -6
  37. package/dist/mixins/async.d.ts +4 -6
  38. package/dist/mixins/async.js +3 -1
  39. package/dist/mixins/mutexed.d.ts +4 -4
  40. package/dist/mixins/mutexed.js +7 -5
  41. package/dist/mixins/readonly.js +14 -15
  42. package/dist/mixins/shared.d.ts +5 -5
  43. package/dist/mixins/sync.d.ts +2 -2
  44. package/dist/stats.d.ts +21 -37
  45. package/dist/stats.js +9 -21
  46. package/dist/utils.d.ts +1 -3
  47. package/package.json +4 -4
  48. package/src/backends/backend.ts +7 -11
  49. package/src/backends/fetch.ts +2 -4
  50. package/src/backends/memory.ts +1 -1
  51. package/src/backends/overlay.ts +49 -40
  52. package/src/backends/port/fs.ts +11 -14
  53. package/src/backends/port/rpc.ts +1 -0
  54. package/src/backends/store/fs.ts +30 -46
  55. package/src/backends/store/simple.ts +1 -1
  56. package/src/backends/store/store.ts +7 -13
  57. package/src/config.ts +26 -26
  58. package/src/emulation/async.ts +28 -178
  59. package/src/emulation/path.ts +4 -11
  60. package/src/emulation/promises.ts +34 -116
  61. package/src/emulation/shared.ts +8 -6
  62. package/src/emulation/sync.ts +41 -185
  63. package/src/error.ts +7 -11
  64. package/src/file.ts +47 -180
  65. package/src/filesystem.ts +14 -65
  66. package/src/mixins/async.ts +4 -6
  67. package/src/mixins/mutexed.ts +4 -4
  68. package/src/mixins/readonly.ts +15 -15
  69. package/src/mixins/shared.ts +5 -5
  70. package/src/mixins/sync.ts +3 -3
  71. package/src/stats.ts +21 -38
@@ -12,11 +12,6 @@ import { dirname, join, parse } from './path.js';
12
12
  import { _statfs, fd2file, fdMap, file2fd, fixError, mounts, resolveMount } from './shared.js';
13
13
  import { emitChange } from './watchers.js';
14
14
 
15
- /**
16
- * Synchronous rename.
17
- * @param oldPath
18
- * @param newPath
19
- */
20
15
  export function renameSync(oldPath: fs.PathLike, newPath: fs.PathLike): void {
21
16
  oldPath = normalizePath(oldPath);
22
17
  newPath = normalizePath(newPath);
@@ -42,8 +37,7 @@ export function renameSync(oldPath: fs.PathLike, newPath: fs.PathLike): void {
42
37
  renameSync satisfies typeof fs.renameSync;
43
38
 
44
39
  /**
45
- * Test whether or not the given path exists by checking with the file system.
46
- * @param path
40
+ * Test whether or not `path` exists by checking with the file system.
47
41
  */
48
42
  export function existsSync(path: fs.PathLike): boolean {
49
43
  path = normalizePath(path);
@@ -60,11 +54,6 @@ export function existsSync(path: fs.PathLike): boolean {
60
54
  }
61
55
  existsSync satisfies typeof fs.existsSync;
62
56
 
63
- /**
64
- * Synchronous `stat`.
65
- * @param path
66
- * @returns Stats
67
- */
68
57
  export function statSync(path: fs.PathLike, options?: { bigint?: boolean }): Stats;
69
58
  export function statSync(path: fs.PathLike, options: { bigint: true }): BigIntStats;
70
59
  export function statSync(path: fs.PathLike, options?: fs.StatOptions): Stats | BigIntStats {
@@ -86,7 +75,6 @@ statSync satisfies typeof fs.statSync;
86
75
  * Synchronous `lstat`.
87
76
  * `lstat()` is identical to `stat()`, except that if path is a symbolic link,
88
77
  * then the link itself is stat-ed, not the file that it refers to.
89
- * @param path
90
78
  */
91
79
  export function lstatSync(path: fs.PathLike, options?: { bigint?: boolean }): Stats;
92
80
  export function lstatSync(path: fs.PathLike, options: { bigint: true }): BigIntStats;
@@ -102,11 +90,6 @@ export function lstatSync(path: fs.PathLike, options?: fs.StatOptions): Stats |
102
90
  }
103
91
  lstatSync satisfies typeof fs.lstatSync;
104
92
 
105
- /**
106
- * Synchronous `truncate`.
107
- * @param path
108
- * @param len
109
- */
110
93
  export function truncateSync(path: fs.PathLike, len: number | null = 0): void {
111
94
  using file = _openSync(path, 'r+');
112
95
  len ||= 0;
@@ -117,10 +100,6 @@ export function truncateSync(path: fs.PathLike, len: number | null = 0): void {
117
100
  }
118
101
  truncateSync satisfies typeof fs.truncateSync;
119
102
 
120
- /**
121
- * Synchronous `unlink`.
122
- * @param path
123
- */
124
103
  export function unlinkSync(path: fs.PathLike): void {
125
104
  path = normalizePath(path);
126
105
  const { fs, path: resolved } = resolveMount(path);
@@ -182,10 +161,6 @@ function _openSync(path: fs.PathLike, _flag: fs.OpenMode, _mode?: fs.Mode | null
182
161
  /**
183
162
  * Synchronous file open.
184
163
  * @see http://www.manpagez.com/man/2/open/
185
- * @param flags Handles the complexity of the various file
186
- * modes. See its API for more details.
187
- * @param mode Mode to use to open the file. Can be ignored if the
188
- * filesystem doesn't support permissions.
189
164
  */
190
165
  export function openSync(path: fs.PathLike, flag: fs.OpenMode, mode: fs.Mode | null = constants.F_OK): number {
191
166
  return file2fd(_openSync(path, flag, mode, true));
@@ -200,9 +175,6 @@ export function lopenSync(path: fs.PathLike, flag: string, mode?: fs.Mode | null
200
175
  return file2fd(_openSync(path, flag, mode, false));
201
176
  }
202
177
 
203
- /**
204
- * Synchronously reads the entire contents of a file.
205
- */
206
178
  function _readFileSync(fname: string, flag: string, resolveSymlinks: boolean): Uint8Array {
207
179
  // Get file.
208
180
  using file = _openSync(fname, flag, 0o644, resolveSymlinks);
@@ -215,10 +187,8 @@ function _readFileSync(fname: string, flag: string, resolveSymlinks: boolean): U
215
187
 
216
188
  /**
217
189
  * Synchronously reads the entire contents of a file.
218
- * @param path
219
- * @param options
220
- * @option options encoding The string encoding for the file contents. Defaults to `null`.
221
- * @option options flag Defaults to `'r'`.
190
+ * @option encoding The string encoding for the file contents. Defaults to `null`.
191
+ * @option flag Defaults to `'r'`.
222
192
  * @returns file contents
223
193
  */
224
194
  export function readFileSync(path: fs.PathOrFileDescriptor, options?: { flag?: string } | null): Buffer;
@@ -235,16 +205,12 @@ export function readFileSync(path: fs.PathOrFileDescriptor, _options: fs.WriteFi
235
205
  readFileSync satisfies typeof fs.readFileSync;
236
206
 
237
207
  /**
238
- * Synchronously writes data to a file, replacing the file if it already
239
- * exists.
208
+ * Synchronously writes data to a file, replacing the file if it already exists.
240
209
  *
241
210
  * The encoding option is ignored if data is a buffer.
242
- * @param path
243
- * @param data
244
- * @param options
245
- * @option options encoding Defaults to `'utf8'`.
246
- * @option options mode Defaults to `0644`.
247
- * @option options flag Defaults to `'w'`.
211
+ * @option encoding Defaults to `'utf8'`.
212
+ * @option mode Defaults to `0644`.
213
+ * @option flag Defaults to `'w'`.
248
214
  */
249
215
  export function writeFileSync(path: fs.PathOrFileDescriptor, data: FileContents, options?: fs.WriteFileOptions): void;
250
216
  export function writeFileSync(path: fs.PathOrFileDescriptor, data: FileContents, encoding?: BufferEncoding): void;
@@ -268,15 +234,10 @@ export function writeFileSync(path: fs.PathOrFileDescriptor, data: FileContents,
268
234
  writeFileSync satisfies typeof fs.writeFileSync;
269
235
 
270
236
  /**
271
- * Asynchronously append data to a file, creating the file if it not yet
272
- * exists.
273
- *
274
- * @param filename
275
- * @param data
276
- * @param options
277
- * @option options encoding Defaults to `'utf8'`.
278
- * @option options mode Defaults to `0644`.
279
- * @option options flag Defaults to `'a'`.
237
+ * Asynchronously append data to a file, creating the file if it not yet exists.
238
+ * @option encoding Defaults to `'utf8'`.
239
+ * @option mode Defaults to `0644`.
240
+ * @option flag Defaults to `'a'`.
280
241
  */
281
242
  export function appendFileSync(filename: fs.PathOrFileDescriptor, data: FileContents, _options: fs.WriteFileOptions = {}): void {
282
243
  const options = normalizeOptions(_options, 'utf8', 'a', 0o644);
@@ -297,7 +258,6 @@ appendFileSync satisfies typeof fs.appendFileSync;
297
258
  * Synchronous `fstat`.
298
259
  * `fstat()` is identical to `stat()`, except that the file to be stat-ed is
299
260
  * specified by the file descriptor `fd`.
300
- * @param fd
301
261
  */
302
262
  export function fstatSync(fd: number, options?: { bigint?: boolean }): Stats;
303
263
  export function fstatSync(fd: number, options: { bigint: true }): BigIntStats;
@@ -307,21 +267,12 @@ export function fstatSync(fd: number, options?: fs.StatOptions): Stats | BigIntS
307
267
  }
308
268
  fstatSync satisfies typeof fs.fstatSync;
309
269
 
310
- /**
311
- * Synchronous close.
312
- * @param fd
313
- */
314
270
  export function closeSync(fd: number): void {
315
271
  fd2file(fd).closeSync();
316
272
  fdMap.delete(fd);
317
273
  }
318
274
  closeSync satisfies typeof fs.closeSync;
319
275
 
320
- /**
321
- * Synchronous ftruncate.
322
- * @param fd
323
- * @param len
324
- */
325
276
  export function ftruncateSync(fd: number, len: number | null = 0): void {
326
277
  len ||= 0;
327
278
  if (len < 0) {
@@ -331,19 +282,11 @@ export function ftruncateSync(fd: number, len: number | null = 0): void {
331
282
  }
332
283
  ftruncateSync satisfies typeof fs.ftruncateSync;
333
284
 
334
- /**
335
- * Synchronous fsync.
336
- * @param fd
337
- */
338
285
  export function fsyncSync(fd: number): void {
339
286
  fd2file(fd).syncSync();
340
287
  }
341
288
  fsyncSync satisfies typeof fs.fsyncSync;
342
289
 
343
- /**
344
- * Synchronous fdatasync.
345
- * @param fd
346
- */
347
290
  export function fdatasyncSync(fd: number): void {
348
291
  fd2file(fd).datasyncSync();
349
292
  }
@@ -351,16 +294,11 @@ fdatasyncSync satisfies typeof fs.fdatasyncSync;
351
294
 
352
295
  /**
353
296
  * Write buffer to the file specified by `fd`.
354
- * Note that it is unsafe to use fs.write multiple times on the same file
355
- * without waiting for it to return.
356
- * @param fd
357
- * @param data Uint8Array containing the data to write to
358
- * the file.
297
+ * @param data Uint8Array containing the data to write to the file.
359
298
  * @param offset Offset in the buffer to start reading data from.
360
299
  * @param length The amount of bytes to write to the file.
361
- * @param position Offset from the beginning of the file where this
362
- * data should be written. If position is null, the data will be written at
363
- * the current position.
300
+ * @param position Offset from the beginning of the file where this data should be written.
301
+ * If position is null, the data will be written at the current position.
364
302
  */
365
303
  export function writeSync(fd: number, data: ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
366
304
  export function writeSync(fd: number, data: string, position?: number | null, encoding?: BufferEncoding | null): number;
@@ -389,26 +327,22 @@ export function writeSync(fd: number, data: FileContents, posOrOff?: number | nu
389
327
  }
390
328
  writeSync satisfies typeof fs.writeSync;
391
329
 
330
+ export function readSync(fd: number, buffer: ArrayBufferView, options?: fs.ReadSyncOptions): number;
331
+ export function readSync(fd: number, buffer: ArrayBufferView, offset: number, length: number, position?: fs.ReadPosition | null): number;
392
332
  /**
393
333
  * Read data from the file specified by `fd`.
394
- * @param fd
395
- * @param buffer The buffer that the data will be
396
- * written to.
397
- * @param offset The offset within the buffer where writing will
398
- * start.
334
+ * @param buffer The buffer that the data will be written to.
335
+ * @param offset The offset within the buffer where writing will start.
399
336
  * @param length An integer specifying the number of bytes to read.
400
- * @param position An integer specifying where to begin reading from
401
- * in the file. If position is null, data will be read from the current file
402
- * position.
337
+ * @param position An integer specifying where to begin reading from in the file.
338
+ * If position is null, data will be read from the current file position.
403
339
  */
404
- export function readSync(fd: number, buffer: ArrayBufferView, opts?: fs.ReadSyncOptions): number;
405
- export function readSync(fd: number, buffer: ArrayBufferView, offset: number, length: number, position?: fs.ReadPosition | null): number;
406
- export function readSync(fd: number, buffer: ArrayBufferView, opts?: fs.ReadSyncOptions | number, length?: number, position?: fs.ReadPosition | null): number {
340
+ export function readSync(fd: number, buffer: ArrayBufferView, options?: fs.ReadSyncOptions | number, length?: number, position?: fs.ReadPosition | null): number {
407
341
  const file = fd2file(fd);
408
- const offset = typeof opts == 'object' ? opts.offset : opts;
409
- if (typeof opts == 'object') {
410
- length = opts.length;
411
- position = opts.position;
342
+ const offset = typeof options == 'object' ? options.offset : options;
343
+ if (typeof options == 'object') {
344
+ length = options.length;
345
+ position = options.position;
412
346
  }
413
347
 
414
348
  position = Number(position);
@@ -420,22 +354,11 @@ export function readSync(fd: number, buffer: ArrayBufferView, opts?: fs.ReadSync
420
354
  }
421
355
  readSync satisfies typeof fs.readSync;
422
356
 
423
- /**
424
- * Synchronous `fchown`.
425
- * @param fd
426
- * @param uid
427
- * @param gid
428
- */
429
357
  export function fchownSync(fd: number, uid: number, gid: number): void {
430
358
  fd2file(fd).chownSync(uid, gid);
431
359
  }
432
360
  fchownSync satisfies typeof fs.fchownSync;
433
361
 
434
- /**
435
- * Synchronous `fchmod`.
436
- * @param fd
437
- * @param mode
438
- */
439
362
  export function fchmodSync(fd: number, mode: number | string): void {
440
363
  const numMode = normalizeMode(mode, -1);
441
364
  if (numMode < 0) {
@@ -446,21 +369,13 @@ export function fchmodSync(fd: number, mode: number | string): void {
446
369
  fchmodSync satisfies typeof fs.fchmodSync;
447
370
 
448
371
  /**
449
- * Change the file timestamps of a file referenced by the supplied file
450
- * descriptor.
451
- * @param fd
452
- * @param atime
453
- * @param mtime
372
+ * Change the file timestamps of a file referenced by the supplied file descriptor.
454
373
  */
455
374
  export function futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void {
456
375
  fd2file(fd).utimesSync(normalizeTime(atime), normalizeTime(mtime));
457
376
  }
458
377
  futimesSync satisfies typeof fs.futimesSync;
459
378
 
460
- /**
461
- * Synchronous `rmdir`.
462
- * @param path
463
- */
464
379
  export function rmdirSync(path: fs.PathLike): void {
465
380
  path = normalizePath(path);
466
381
  const { fs, path: resolved } = resolveMount(existsSync(path) ? realpathSync(path) : path);
@@ -477,9 +392,7 @@ export function rmdirSync(path: fs.PathLike): void {
477
392
  rmdirSync satisfies typeof fs.rmdirSync;
478
393
 
479
394
  /**
480
- * Synchronous `mkdir`.
481
- * @param path
482
- * @param mode defaults to o777
395
+ * Synchronous `mkdir`. Mode defaults to `o777`.
483
396
  */
484
397
  export function mkdirSync(path: fs.PathLike, options: fs.MakeDirectoryOptions & { recursive: true }): string | undefined;
485
398
  export function mkdirSync(path: fs.PathLike, options?: fs.Mode | (fs.MakeDirectoryOptions & { recursive?: false }) | null): void;
@@ -520,10 +433,6 @@ export function mkdirSync(path: fs.PathLike, options?: fs.Mode | fs.MakeDirector
520
433
  }
521
434
  mkdirSync satisfies typeof fs.mkdirSync;
522
435
 
523
- /**
524
- * Synchronous `readdir`. Reads the contents of a directory.
525
- * @param path
526
- */
527
436
  export function readdirSync(path: fs.PathLike, options?: { recursive?: boolean; encoding?: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): string[];
528
437
  export function readdirSync(path: fs.PathLike, options: { recursive?: boolean; encoding: 'buffer'; withFileTypes?: false } | 'buffer'): Buffer[];
529
438
  export function readdirSync(path: fs.PathLike, options: { recursive?: boolean; withFileTypes: true }): Dirent[];
@@ -570,11 +479,6 @@ readdirSync satisfies typeof fs.readdirSync;
570
479
 
571
480
  // SYMLINK METHODS
572
481
 
573
- /**
574
- * Synchronous `link`.
575
- * @param targetPath
576
- * @param linkPath
577
- */
578
482
  export function linkSync(targetPath: fs.PathLike, linkPath: fs.PathLike): void {
579
483
  targetPath = normalizePath(targetPath);
580
484
  if (!statSync(dirname(targetPath)).hasAccess(constants.R_OK)) {
@@ -621,10 +525,6 @@ export function symlinkSync(target: fs.PathLike, path: fs.PathLike, type: fs.sym
621
525
  }
622
526
  symlinkSync satisfies typeof fs.symlinkSync;
623
527
 
624
- /**
625
- * Synchronous readlink.
626
- * @param path
627
- */
628
528
  export function readlinkSync(path: fs.PathLike, options?: fs.BufferEncodingOption): Buffer;
629
529
  export function readlinkSync(path: fs.PathLike, options: fs.EncodingOption | BufferEncoding): string;
630
530
  export function readlinkSync(path: fs.PathLike, options?: fs.EncodingOption | BufferEncoding | fs.BufferEncodingOption): Buffer | string;
@@ -640,12 +540,6 @@ readlinkSync satisfies typeof fs.readlinkSync;
640
540
 
641
541
  // PROPERTY OPERATIONS
642
542
 
643
- /**
644
- * Synchronous `chown`.
645
- * @param path
646
- * @param uid
647
- * @param gid
648
- */
649
543
  export function chownSync(path: fs.PathLike, uid: number, gid: number): void {
650
544
  const fd = openSync(path, 'r+');
651
545
  fchownSync(fd, uid, gid);
@@ -653,12 +547,6 @@ export function chownSync(path: fs.PathLike, uid: number, gid: number): void {
653
547
  }
654
548
  chownSync satisfies typeof fs.chownSync;
655
549
 
656
- /**
657
- * Synchronous `lchown`.
658
- * @param path
659
- * @param uid
660
- * @param gid
661
- */
662
550
  export function lchownSync(path: fs.PathLike, uid: number, gid: number): void {
663
551
  const fd = lopenSync(path, 'r+');
664
552
  fchownSync(fd, uid, gid);
@@ -666,11 +554,6 @@ export function lchownSync(path: fs.PathLike, uid: number, gid: number): void {
666
554
  }
667
555
  lchownSync satisfies typeof fs.lchownSync;
668
556
 
669
- /**
670
- * Synchronous `chmod`.
671
- * @param path
672
- * @param mode
673
- */
674
557
  export function chmodSync(path: fs.PathLike, mode: fs.Mode): void {
675
558
  const fd = openSync(path, 'r+');
676
559
  fchmodSync(fd, mode);
@@ -678,11 +561,6 @@ export function chmodSync(path: fs.PathLike, mode: fs.Mode): void {
678
561
  }
679
562
  chmodSync satisfies typeof fs.chmodSync;
680
563
 
681
- /**
682
- * Synchronous `lchmod`.
683
- * @param path
684
- * @param mode
685
- */
686
564
  export function lchmodSync(path: fs.PathLike, mode: number | string): void {
687
565
  const fd = lopenSync(path, 'r+');
688
566
  fchmodSync(fd, mode);
@@ -692,9 +570,6 @@ lchmodSync satisfies typeof fs.lchmodSync;
692
570
 
693
571
  /**
694
572
  * Change file timestamps of the file referenced by the supplied path.
695
- * @param path
696
- * @param atime
697
- * @param mtime
698
573
  */
699
574
  export function utimesSync(path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date): void {
700
575
  const fd = openSync(path, 'r+');
@@ -705,9 +580,6 @@ utimesSync satisfies typeof fs.utimesSync;
705
580
 
706
581
  /**
707
582
  * Change file timestamps of the file referenced by the supplied path.
708
- * @param path
709
- * @param atime
710
- * @param mtime
711
583
  */
712
584
  export function lutimesSync(path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date): void {
713
585
  const fd = lopenSync(path, 'r+');
@@ -716,14 +588,6 @@ export function lutimesSync(path: fs.PathLike, atime: string | number | Date, mt
716
588
  }
717
589
  lutimesSync satisfies typeof fs.lutimesSync;
718
590
 
719
- /**
720
- * Synchronous `realpath`.
721
- * @param path
722
- * @param cache An object literal of mapped paths that can be used to
723
- * force a specific path resolution or avoid additional `fs.stat` calls for
724
- * known real paths.
725
- * @returns the real path
726
- */
727
591
  export function realpathSync(path: fs.PathLike, options: fs.BufferEncodingOption): Buffer;
728
592
  export function realpathSync(path: fs.PathLike, options?: fs.EncodingOption): string;
729
593
  export function realpathSync(path: fs.PathLike, options?: fs.EncodingOption | fs.BufferEncodingOption): string | Buffer {
@@ -745,11 +609,6 @@ export function realpathSync(path: fs.PathLike, options?: fs.EncodingOption | fs
745
609
  }
746
610
  realpathSync satisfies Omit<typeof fs.realpathSync, 'native'>;
747
611
 
748
- /**
749
- * Synchronous `access`.
750
- * @param path
751
- * @param mode
752
- */
753
612
  export function accessSync(path: fs.PathLike, mode: number = 0o600): void {
754
613
  const stats = statSync(path);
755
614
  if (!stats.hasAccess(mode)) {
@@ -812,21 +671,19 @@ mkdtempSync satisfies typeof fs.mkdtempSync;
812
671
 
813
672
  /**
814
673
  * Synchronous `copyFile`. Copies a file.
815
- * @param src The source file.
816
- * @param dest The destination file.
817
674
  * @param flags Optional flags for the copy operation. Currently supports these flags:
818
- * * `fs.constants.COPYFILE_EXCL`: If the destination file already exists, the operation fails.
675
+ * - `fs.constants.COPYFILE_EXCL`: If the destination file already exists, the operation fails.
819
676
  */
820
- export function copyFileSync(src: fs.PathLike, dest: fs.PathLike, flags?: number): void {
821
- src = normalizePath(src);
822
- dest = normalizePath(dest);
677
+ export function copyFileSync(source: fs.PathLike, destination: fs.PathLike, flags?: number): void {
678
+ source = normalizePath(source);
679
+ destination = normalizePath(destination);
823
680
 
824
- if (flags && flags & constants.COPYFILE_EXCL && existsSync(dest)) {
825
- throw new ErrnoError(Errno.EEXIST, 'Destination file already exists.', dest, 'copyFile');
681
+ if (flags && flags & constants.COPYFILE_EXCL && existsSync(destination)) {
682
+ throw new ErrnoError(Errno.EEXIST, 'Destination file already exists.', destination, 'copyFile');
826
683
  }
827
684
 
828
- writeFileSync(dest, readFileSync(src));
829
- emitChange('rename', dest.toString());
685
+ writeFileSync(destination, readFileSync(source));
686
+ emitChange('rename', destination.toString());
830
687
  }
831
688
  copyFileSync satisfies typeof fs.copyFileSync;
832
689
 
@@ -885,12 +742,12 @@ opendirSync satisfies typeof fs.opendirSync;
885
742
  * @param source The source file or directory.
886
743
  * @param destination The destination file or directory.
887
744
  * @param opts Options for the copy operation. Currently supports these options from Node.js 'fs.cpSync':
888
- * * `dereference`: Dereference symbolic links.
889
- * * `errorOnExist`: Throw an error if the destination file or directory already exists.
890
- * * `filter`: A function that takes a source and destination path and returns a boolean, indicating whether to copy the given source element.
891
- * * `force`: Overwrite the destination if it exists, and overwrite existing readonly destination files.
892
- * * `preserveTimestamps`: Preserve file timestamps.
893
- * * `recursive`: If `true`, copies directories recursively.
745
+ * - `dereference`: Dereference symbolic links. *(unconfirmed)*
746
+ * - `errorOnExist`: Throw an error if the destination file or directory already exists.
747
+ * - `filter`: A function that takes a source and destination path and returns a boolean, indicating whether to copy `source` element.
748
+ * - `force`: Overwrite the destination if it exists, and overwrite existing readonly destination files. *(unconfirmed)*
749
+ * - `preserveTimestamps`: Preserve file timestamps.
750
+ * - `recursive`: If `true`, copies directories recursively.
894
751
  */
895
752
  export function cpSync(source: fs.PathLike, destination: fs.PathLike, opts?: fs.CopySyncOptions): void {
896
753
  source = normalizePath(source);
@@ -938,7 +795,6 @@ cpSync satisfies typeof fs.cpSync;
938
795
  * Synchronous statfs(2). Returns information about the mounted file system which contains path.
939
796
  * In case of an error, the err.code will be one of Common System Errors.
940
797
  * @param path A path to an existing file or directory on the file system to be queried.
941
- * @param callback
942
798
  */
943
799
  export function statfsSync(path: fs.PathLike, options?: fs.StatFsOptions & { bigint?: false }): fs.StatsFs;
944
800
  export function statfsSync(path: fs.PathLike, options: fs.StatFsOptions & { bigint: true }): fs.BigIntStatsFs;
package/src/error.ts CHANGED
@@ -244,8 +244,7 @@ export interface ErrnoErrorJSON {
244
244
  }
245
245
 
246
246
  /**
247
- * Represents a ZenFS error. Passed back to applications after a failed
248
- * call to the ZenFS API.
247
+ * An error with additional information about what happened
249
248
  */
250
249
  export class ErrnoError extends Error implements NodeJS.ErrnoException {
251
250
  public static fromJSON(json: ErrnoErrorJSON): ErrnoError {
@@ -263,17 +262,14 @@ export class ErrnoError extends Error implements NodeJS.ErrnoException {
263
262
 
264
263
  public declare stack: string;
265
264
 
266
- /**
267
- * Represents a ZenFS error. Passed back to applications after a failed
268
- * call to the ZenFS API.
269
- *
270
- * Error codes mirror those returned by regular Unix file operations, which is
271
- * what Node returns.
272
- * @param type The type of the error.
273
- * @param message A descriptive error message.
274
- */
275
265
  public constructor(
266
+ /**
267
+ * The kind of error
268
+ */
276
269
  public errno: Errno,
270
+ /**
271
+ * A descriptive error message
272
+ */
277
273
  message: string = errorMessages[errno],
278
274
  public path?: string,
279
275
  public syscall: string = ''