@zenfs/core 1.0.10 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) 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/file_index.js +3 -3
  6. package/dist/backends/memory.d.ts +1 -1
  7. package/dist/backends/overlay.d.ts +7 -3
  8. package/dist/backends/overlay.js +13 -9
  9. package/dist/backends/port/fs.d.ts +12 -17
  10. package/dist/backends/port/fs.js +5 -8
  11. package/dist/backends/port/rpc.d.ts +1 -1
  12. package/dist/backends/store/fs.d.ts +13 -15
  13. package/dist/backends/store/fs.js +35 -54
  14. package/dist/backends/store/simple.d.ts +1 -1
  15. package/dist/backends/store/simple.js +1 -1
  16. package/dist/backends/store/store.d.ts +7 -13
  17. package/dist/config.d.ts +13 -5
  18. package/dist/config.js +36 -26
  19. package/dist/devices.d.ts +158 -0
  20. package/dist/devices.js +423 -0
  21. package/dist/emulation/async.d.ts +21 -176
  22. package/dist/emulation/async.js +17 -111
  23. package/dist/emulation/constants.d.ts +5 -0
  24. package/dist/emulation/constants.js +5 -0
  25. package/dist/emulation/dir.d.ts +0 -1
  26. package/dist/emulation/path.d.ts +0 -4
  27. package/dist/emulation/path.js +4 -8
  28. package/dist/emulation/promises.d.ts +31 -121
  29. package/dist/emulation/promises.js +30 -97
  30. package/dist/emulation/shared.d.ts +7 -3
  31. package/dist/emulation/shared.js +11 -7
  32. package/dist/emulation/streams.d.ts +0 -3
  33. package/dist/emulation/sync.d.ts +25 -178
  34. package/dist/emulation/sync.js +36 -129
  35. package/dist/emulation/watchers.d.ts +0 -4
  36. package/dist/error.d.ts +11 -11
  37. package/dist/error.js +8 -10
  38. package/dist/file.d.ts +50 -171
  39. package/dist/file.js +34 -117
  40. package/dist/filesystem.d.ts +10 -62
  41. package/dist/filesystem.js +5 -6
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.js +2 -0
  44. package/dist/inode.d.ts +0 -5
  45. package/dist/inode.js +0 -5
  46. package/dist/mixins/async.d.ts +4 -6
  47. package/dist/mixins/async.js +3 -1
  48. package/dist/mixins/mutexed.d.ts +4 -4
  49. package/dist/mixins/mutexed.js +7 -5
  50. package/dist/mixins/readonly.js +14 -15
  51. package/dist/mixins/shared.d.ts +5 -5
  52. package/dist/mixins/sync.d.ts +2 -2
  53. package/dist/stats.d.ts +21 -37
  54. package/dist/stats.js +10 -23
  55. package/dist/utils.d.ts +15 -7
  56. package/dist/utils.js +28 -6
  57. package/package.json +4 -4
  58. package/readme.md +58 -2
  59. package/src/backends/backend.ts +7 -11
  60. package/src/backends/fetch.ts +2 -4
  61. package/src/backends/file_index.ts +3 -3
  62. package/src/backends/memory.ts +1 -1
  63. package/src/backends/overlay.ts +11 -9
  64. package/src/backends/port/fs.ts +11 -14
  65. package/src/backends/port/rpc.ts +1 -0
  66. package/src/backends/store/fs.ts +40 -55
  67. package/src/backends/store/simple.ts +1 -1
  68. package/src/backends/store/store.ts +7 -13
  69. package/src/config.ts +48 -26
  70. package/src/devices.ts +469 -0
  71. package/src/emulation/async.ts +28 -178
  72. package/src/emulation/constants.ts +6 -0
  73. package/src/emulation/path.ts +4 -11
  74. package/src/emulation/promises.ts +34 -116
  75. package/src/emulation/shared.ts +11 -8
  76. package/src/emulation/sync.ts +41 -185
  77. package/src/error.ts +7 -11
  78. package/src/file.ts +48 -182
  79. package/src/filesystem.ts +14 -65
  80. package/src/index.ts +2 -0
  81. package/src/inode.ts +0 -6
  82. package/src/mixins/async.ts +4 -6
  83. package/src/mixins/mutexed.ts +4 -4
  84. package/src/mixins/readonly.ts +15 -15
  85. package/src/mixins/shared.ts +5 -5
  86. package/src/mixins/sync.ts +3 -3
  87. package/src/stats.ts +22 -40
  88. package/src/utils.ts +33 -6
@@ -77,14 +77,14 @@ export class FileHandle implements promises.FileHandle {
77
77
 
78
78
  /**
79
79
  * Asynchronous ftruncate(2) - Truncate a file to a specified length.
80
- * @param len If not specified, defaults to `0`.
80
+ * @param length If not specified, defaults to `0`.
81
81
  */
82
- public async truncate(len?: number | null): Promise<void> {
83
- len ||= 0;
84
- if (len < 0) {
82
+ public async truncate(length?: number | null): Promise<void> {
83
+ length ||= 0;
84
+ if (length < 0) {
85
85
  throw new ErrnoError(Errno.EINVAL);
86
86
  }
87
- await this.file.truncate(len);
87
+ await this.file.truncate(length);
88
88
  emitChange('change', this.file.path);
89
89
  }
90
90
 
@@ -103,10 +103,9 @@ export class FileHandle implements promises.FileHandle {
103
103
  * The `FileHandle` must have been opened for appending.
104
104
  * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
105
105
  * @param _options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
106
- * If `encoding` is not supplied, the default of `'utf8'` is used.
107
- * If `mode` is not supplied, the default of `0o666` is used.
108
- * If `mode` is a string, it is parsed as an octal integer.
109
- * If `flag` is not supplied, the default of `'a'` is used.
106
+ * - `encoding` defaults to `'utf8'`.
107
+ * - `mode` defaults to `0o666`.
108
+ * - `flag` defaults to `'a'`.
110
109
  */
111
110
  public async appendFile(data: string | Uint8Array, _options: (fs.ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding = {}): Promise<void> {
112
111
  const options = normalizeOptions(_options, 'utf8', 'a', 0o644);
@@ -161,10 +160,11 @@ export class FileHandle implements promises.FileHandle {
161
160
  /**
162
161
  * Returns a `ReadableStream` that may be used to read the files data.
163
162
  *
164
- * An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed
165
- * or closing.
163
+ * An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed or closing.
166
164
  *
167
- * While the `ReadableStream` will read the file to completion, it will not close the `FileHandle` automatically. User code must still call the `fileHandle.close()` method.
165
+ * While the `ReadableStream` will read the file to completion,
166
+ * it will not close the `FileHandle` automatically.
167
+ * User code must still call the `fileHandle.close()` method.
168
168
  *
169
169
  * @since v17.0.0
170
170
  * @experimental
@@ -272,10 +272,9 @@ export class FileHandle implements promises.FileHandle {
272
272
  * It is unsafe to call `writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected).
273
273
  * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
274
274
  * @param _options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
275
- * If `encoding` is not supplied, the default of `'utf8'` is used.
276
- * If `mode` is not supplied, the default of `0o666` is used.
277
- * If `mode` is a string, it is parsed as an octal integer.
278
- * If `flag` is not supplied, the default of `'w'` is used.
275
+ * - `encoding` defaults to `'utf8'`.
276
+ * - `mode` defaults to `0o666`.
277
+ * - `flag` defaults to `'w'`.
279
278
  */
280
279
  public async writeFile(data: string | Uint8Array, _options: fs.WriteFileOptions = {}): Promise<void> {
281
280
  const options = normalizeOptions(_options, 'utf8', 'w', 0o644);
@@ -332,10 +331,8 @@ export class FileHandle implements promises.FileHandle {
332
331
  }
333
332
 
334
333
  /**
335
- * Creates a `ReadStream` for reading from the file.
336
- *
334
+ * Creates a stream for reading from the file.
337
335
  * @param options Options for the readable stream
338
- * @returns A `ReadStream` object.
339
336
  */
340
337
  public createReadStream(options?: CreateReadStreamOptions): ReadStream {
341
338
  const stream = new ReadStream({
@@ -359,10 +356,8 @@ export class FileHandle implements promises.FileHandle {
359
356
  }
360
357
 
361
358
  /**
362
- * Creates a `WriteStream` for writing to the file.
363
- *
359
+ * Creates a stream for writing to the file.
364
360
  * @param options Options for the writeable stream.
365
- * @returns A `WriteStream` object
366
361
  */
367
362
  public createWriteStream(options?: CreateWriteStreamOptions): WriteStream {
368
363
  const streamOptions = {
@@ -385,11 +380,6 @@ export class FileHandle implements promises.FileHandle {
385
380
  }
386
381
  }
387
382
 
388
- /**
389
- * Renames a file
390
- * @param oldPath
391
- * @param newPath
392
- */
393
383
  export async function rename(oldPath: fs.PathLike, newPath: fs.PathLike): Promise<void> {
394
384
  oldPath = normalizePath(oldPath);
395
385
  newPath = normalizePath(newPath);
@@ -414,8 +404,7 @@ export async function rename(oldPath: fs.PathLike, newPath: fs.PathLike): Promis
414
404
  rename satisfies typeof promises.rename;
415
405
 
416
406
  /**
417
- * Test whether or not the given path exists by checking with the file system.
418
- * @param path
407
+ * Test whether or not `path` exists by checking with the file system.
419
408
  */
420
409
  export async function exists(path: fs.PathLike): Promise<boolean> {
421
410
  try {
@@ -430,11 +419,6 @@ export async function exists(path: fs.PathLike): Promise<boolean> {
430
419
  }
431
420
  }
432
421
 
433
- /**
434
- * `stat`.
435
- * @param path
436
- * @returns Stats
437
- */
438
422
  export async function stat(path: fs.PathLike, options: fs.BigIntOptions): Promise<BigIntStats>;
439
423
  export async function stat(path: fs.PathLike, options?: { bigint?: false }): Promise<Stats>;
440
424
  export async function stat(path: fs.PathLike, options?: fs.StatOptions): Promise<Stats | BigIntStats>;
@@ -457,8 +441,6 @@ stat satisfies typeof promises.stat;
457
441
  * `lstat`.
458
442
  * `lstat()` is identical to `stat()`, except that if path is a symbolic link,
459
443
  * then the link itself is stat-ed, not the file that it refers to.
460
- * @param path
461
- * @return
462
444
  */
463
445
  export async function lstat(path: fs.PathLike, options?: { bigint?: boolean }): Promise<Stats>;
464
446
  export async function lstat(path: fs.PathLike, options: { bigint: true }): Promise<BigIntStats>;
@@ -476,21 +458,12 @@ lstat satisfies typeof promises.lstat;
476
458
 
477
459
  // FILE-ONLY METHODS
478
460
 
479
- /**
480
- * `truncate`.
481
- * @param path
482
- * @param len
483
- */
484
461
  export async function truncate(path: fs.PathLike, len: number = 0): Promise<void> {
485
462
  await using handle = await open(path, 'r+');
486
463
  await handle.truncate(len);
487
464
  }
488
465
  truncate satisfies typeof promises.truncate;
489
466
 
490
- /**
491
- * `unlink`.
492
- * @param path
493
- */
494
467
  export async function unlink(path: fs.PathLike): Promise<void> {
495
468
  path = normalizePath(path);
496
469
  const { fs, path: resolved } = resolveMount(path);
@@ -562,7 +535,7 @@ async function _open(path: fs.PathLike, _flag: fs.OpenMode, _mode: fs.Mode = 0o6
562
535
  /**
563
536
  * Asynchronous file open.
564
537
  * @see http://www.manpagez.com/man/2/open/
565
- * @param flags Handles the complexity of the various file modes. See its API for more details.
538
+ * @param flag Handles the complexity of the various file modes. See its API for more details.
566
539
  * @param mode Mode to use to open the file. Can be ignored if the filesystem doesn't support permissions.
567
540
  */
568
541
  export async function open(path: fs.PathLike, flag: fs.OpenMode = 'r', mode: fs.Mode = 0o644): Promise<FileHandle> {
@@ -572,11 +545,9 @@ open satisfies typeof promises.open;
572
545
 
573
546
  /**
574
547
  * Asynchronously reads the entire contents of a file.
575
- * @param filename
576
- * @param options
577
- * options.encoding The string encoding for the file contents. Defaults to `null`.
578
- * options.flag Defaults to `'r'`.
579
- * @returns file data
548
+ * @option encoding The string encoding for the file contents. Defaults to `null`.
549
+ * @option flag Defaults to `'r'`.
550
+ * @returns the file data
580
551
  */
581
552
  export async function readFile(path: fs.PathLike | promises.FileHandle, options?: { encoding?: null; flag?: fs.OpenMode } | null): Promise<Buffer>;
582
553
  export async function readFile(path: fs.PathLike | promises.FileHandle, options: { encoding: BufferEncoding; flag?: fs.OpenMode } | BufferEncoding): Promise<string>;
@@ -598,12 +569,9 @@ readFile satisfies typeof promises.readFile;
598
569
  * Asynchronously writes data to a file, replacing the file if it already exists.
599
570
  *
600
571
  * The encoding option is ignored if data is a buffer.
601
- * @param path
602
- * @param data Note:
603
- * @param _options
604
- * @option options encoding Defaults to `'utf8'`.
605
- * @option options mode Defaults to `0644`.
606
- * @option options flag Defaults to `'w'`.
572
+ * @option encoding Defaults to `'utf8'`.
573
+ * @option mode Defaults to `0644`.
574
+ * @option flag Defaults to `'w'`.
607
575
  */
608
576
  export async function writeFile(
609
577
  path: fs.PathLike | promises.FileHandle,
@@ -622,14 +590,10 @@ export async function writeFile(
622
590
  writeFile satisfies typeof promises.writeFile;
623
591
 
624
592
  /**
625
- * Asynchronously append data to a file, creating the file if it not yet
626
- * exists.
627
- * @param path
628
- * @param data
629
- * @param options
630
- * @option options encoding Defaults to `'utf8'`.
631
- * @option options mode Defaults to `0644`.
632
- * @option options flag Defaults to `'a'`.
593
+ * Asynchronously append data to a file, creating the file if it not yet exists.
594
+ * @option encoding Defaults to `'utf8'`.
595
+ * @option mode Defaults to `0644`.
596
+ * @option flag Defaults to `'a'`.
633
597
  */
634
598
  export async function appendFile(
635
599
  path: fs.PathLike | promises.FileHandle,
@@ -653,10 +617,6 @@ appendFile satisfies typeof promises.appendFile;
653
617
 
654
618
  // DIRECTORY-ONLY METHODS
655
619
 
656
- /**
657
- * `rmdir`.
658
- * @param path
659
- */
660
620
  export async function rmdir(path: fs.PathLike): Promise<void> {
661
621
  path = normalizePath(path);
662
622
  path = (await exists(path)) ? await realpath(path) : path;
@@ -723,7 +683,7 @@ mkdir satisfies typeof promises.mkdir;
723
683
  /**
724
684
  * Asynchronous readdir(3) - read a directory.
725
685
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
726
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
686
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'`.
727
687
  */
728
688
  export async function readdir(path: fs.PathLike, options?: (fs.ObjectEncodingOptions & { withFileTypes?: false; recursive?: boolean }) | BufferEncoding | null): Promise<string[]>;
729
689
  export async function readdir(path: fs.PathLike, options: fs.BufferEncodingOption & { withFileTypes?: false; recursive?: boolean }): Promise<Buffer[]>;
@@ -768,11 +728,6 @@ readdir satisfies typeof promises.readdir;
768
728
 
769
729
  // SYMLINK METHODS
770
730
 
771
- /**
772
- * `link`.
773
- * @param targetPath
774
- * @param linkPath
775
- */
776
731
  export async function link(targetPath: fs.PathLike, linkPath: fs.PathLike): Promise<void> {
777
732
  targetPath = normalizePath(targetPath);
778
733
  if (!(await stat(dirname(targetPath))).hasAccess(constants.R_OK)) {
@@ -820,10 +775,6 @@ export async function symlink(target: fs.PathLike, path: fs.PathLike, type: fs.s
820
775
  }
821
776
  symlink satisfies typeof promises.symlink;
822
777
 
823
- /**
824
- * readlink.
825
- * @param path
826
- */
827
778
  export async function readlink(path: fs.PathLike, options: fs.BufferEncodingOption): Promise<Buffer>;
828
779
  export async function readlink(path: fs.PathLike, options?: fs.EncodingOption | null): Promise<string>;
829
780
  export async function readlink(path: fs.PathLike, options?: fs.BufferEncodingOption | fs.EncodingOption | string | null): Promise<string | Buffer>;
@@ -837,46 +788,24 @@ readlink satisfies typeof promises.readlink;
837
788
 
838
789
  // PROPERTY OPERATIONS
839
790
 
840
- /**
841
- * `chown`.
842
- * @param path
843
- * @param uid
844
- * @param gid
845
- */
846
791
  export async function chown(path: fs.PathLike, uid: number, gid: number): Promise<void> {
847
792
  await using handle = await open(path, 'r+');
848
793
  await handle.chown(uid, gid);
849
794
  }
850
795
  chown satisfies typeof promises.chown;
851
796
 
852
- /**
853
- * `lchown`.
854
- * @param path
855
- * @param uid
856
- * @param gid
857
- */
858
797
  export async function lchown(path: fs.PathLike, uid: number, gid: number): Promise<void> {
859
798
  await using handle: FileHandle = await _open(path, 'r+', 0o644, false);
860
799
  await handle.chown(uid, gid);
861
800
  }
862
801
  lchown satisfies typeof promises.lchown;
863
802
 
864
- /**
865
- * `chmod`.
866
- * @param path
867
- * @param mode
868
- */
869
803
  export async function chmod(path: fs.PathLike, mode: fs.Mode): Promise<void> {
870
804
  await using handle = await open(path, 'r+');
871
805
  await handle.chmod(mode);
872
806
  }
873
807
  chmod satisfies typeof promises.chmod;
874
808
 
875
- /**
876
- * `lchmod`.
877
- * @param path
878
- * @param mode
879
- */
880
809
  export async function lchmod(path: fs.PathLike, mode: fs.Mode): Promise<void> {
881
810
  await using handle: FileHandle = await _open(path, 'r+', 0o644, false);
882
811
  await handle.chmod(mode);
@@ -885,9 +814,6 @@ lchmod satisfies typeof promises.lchmod;
885
814
 
886
815
  /**
887
816
  * Change file timestamps of the file referenced by the supplied path.
888
- * @param path
889
- * @param atime
890
- * @param mtime
891
817
  */
892
818
  export async function utimes(path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void> {
893
819
  await using handle = await open(path, 'r+');
@@ -897,9 +823,6 @@ utimes satisfies typeof promises.utimes;
897
823
 
898
824
  /**
899
825
  * Change file timestamps of the file referenced by the supplied path.
900
- * @param path
901
- * @param atime
902
- * @param mtime
903
826
  */
904
827
  export async function lutimes(path: fs.PathLike, atime: fs.TimeLike, mtime: fs.TimeLike): Promise<void> {
905
828
  await using handle: FileHandle = await _open(path, 'r+', 0o644, false);
@@ -910,7 +833,7 @@ lutimes satisfies typeof promises.lutimes;
910
833
  /**
911
834
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
912
835
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
913
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
836
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. Defaults to `'utf8'`.
914
837
  */
915
838
  export async function realpath(path: fs.PathLike, options: fs.BufferEncodingOption): Promise<Buffer>;
916
839
  export async function realpath(path: fs.PathLike, options?: fs.EncodingOption | BufferEncoding): Promise<string>;
@@ -961,11 +884,6 @@ export function watch<T extends string | Buffer>(filename: fs.PathLike, options:
961
884
  }
962
885
  watch satisfies typeof promises.watch;
963
886
 
964
- /**
965
- * `access`.
966
- * @param path
967
- * @param mode
968
- */
969
887
  export async function access(path: fs.PathLike, mode: number = constants.F_OK): Promise<void> {
970
888
  const stats = await stat(path);
971
889
  if (!stats.hasAccess(mode)) {
@@ -1066,7 +984,7 @@ opendir satisfies typeof promises.opendir;
1066
984
  * @param opts Options for the copy operation. Currently supports these options from Node.js 'fs.await cp':
1067
985
  * * `dereference`: Dereference symbolic links.
1068
986
  * * `errorOnExist`: Throw an error if the destination file or directory already exists.
1069
- * * `filter`: A function that takes a source and destination path and returns a boolean, indicating whether to copy the given source element.
987
+ * * `filter`: A function that takes a source and destination path and returns a boolean, indicating whether to copy `source` element.
1070
988
  * * `force`: Overwrite the destination if it exists, and overwrite existing readonly destination files.
1071
989
  * * `preserveTimestamps`: Preserve file timestamps.
1072
990
  * * `recursive`: If `true`, copies directories recursively.
@@ -1114,8 +1032,8 @@ export async function cp(source: fs.PathLike, destination: fs.PathLike, opts?: f
1114
1032
  cp satisfies typeof promises.cp;
1115
1033
 
1116
1034
  /**
1117
- * @since v18.15.0
1118
- * @return Fulfills with an {fs.StatFs} for the file system.
1035
+ * @since Node v18.15.0
1036
+ * @returns Fulfills with an {fs.StatFs} for the file system.
1119
1037
  */
1120
1038
  export async function statfs(path: fs.PathLike, opts?: fs.StatFsOptions & { bigint?: false }): Promise<fs.StatsFs>;
1121
1039
  export async function statfs(path: fs.PathLike, opts: fs.StatFsOptions & { bigint: true }): Promise<fs.BigIntStatsFs>;
@@ -5,9 +5,9 @@ import { InMemory } from '../backends/memory.js';
5
5
  import { Errno, ErrnoError } from '../error.js';
6
6
  import type { File } from '../file.js';
7
7
  import type { FileSystem } from '../filesystem.js';
8
- import { size_max } from '../inode.js';
9
8
  import { normalizePath } from '../utils.js';
10
9
  import { resolve, type AbsolutePath } from './path.js';
10
+ import { size_max } from './constants.js';
11
11
 
12
12
  // descriptors
13
13
  export const fdMap: Map<number, File> = new Map();
@@ -24,7 +24,6 @@ export function fd2file(fd: number): File {
24
24
  return fdMap.get(fd)!;
25
25
  }
26
26
 
27
- // mounting
28
27
  export type MountObject = Record<AbsolutePath, FileSystem>;
29
28
 
30
29
  /**
@@ -33,13 +32,11 @@ export type MountObject = Record<AbsolutePath, FileSystem>;
33
32
  */
34
33
  export const mounts: Map<string, FileSystem> = new Map();
35
34
 
36
- /*
37
- Set a default root.
38
- */
35
+ // Set a default root.
39
36
  mount('/', InMemory.create({ name: 'root' }));
40
37
 
41
38
  /**
42
- * Mounts the file system at the given mount point.
39
+ * Mounts the file system at `mountPoint`.
43
40
  */
44
41
  export function mount(mountPoint: string, fs: FileSystem): void {
45
42
  if (mountPoint[0] !== '/') {
@@ -53,7 +50,7 @@ export function mount(mountPoint: string, fs: FileSystem): void {
53
50
  }
54
51
 
55
52
  /**
56
- * Unmounts the file system at the given mount point.
53
+ * Unmounts the file system at `mountPoint`.
57
54
  */
58
55
  export function umount(mountPoint: string): void {
59
56
  if (mountPoint[0] !== '/') {
@@ -71,7 +68,8 @@ export function umount(mountPoint: string): void {
71
68
  */
72
69
  export function resolveMount(path: string): { fs: FileSystem; path: string; mountPoint: string } {
73
70
  path = normalizePath(path);
74
- const sortedMounts = [...mounts].sort((a, b) => (a[0].length > b[0].length ? -1 : 1)); // decending order of the string length
71
+ // Maybe do something for devices here
72
+ const sortedMounts = [...mounts].sort((a, b) => (a[0].length > b[0].length ? -1 : 1)); // descending order of the string length
75
73
  for (const [mountPoint, fs] of sortedMounts) {
76
74
  // We know path is normalized, so it would be a substring of the mount point.
77
75
  if (mountPoint.length <= path.length && path.startsWith(mountPoint)) {
@@ -88,6 +86,7 @@ export function resolveMount(path: string): { fs: FileSystem; path: string; moun
88
86
 
89
87
  /**
90
88
  * Reverse maps the paths in text from the mounted FileSystem to the global path
89
+ * @hidden
91
90
  */
92
91
  export function fixPaths(text: string, paths: Record<string, string>): string {
93
92
  for (const [from, to] of Object.entries(paths)) {
@@ -96,6 +95,10 @@ export function fixPaths(text: string, paths: Record<string, string>): string {
96
95
  return text;
97
96
  }
98
97
 
98
+ /**
99
+ * Fix paths in error stacks
100
+ * @hidden
101
+ */
99
102
  export function fixError<E extends Error>(e: E, paths: Record<string, string>): E {
100
103
  if (typeof e.stack == 'string') {
101
104
  e.stack = fixPaths(e.stack, paths);