@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
@@ -265,14 +265,12 @@ export function basename(path, suffix) {
265
265
  // Try to match the explicit extension
266
266
  if (path[i] === suffix[extIdx]) {
267
267
  if (--extIdx === -1) {
268
- // We matched the extension, so mark this as the end of our path
269
- // component
268
+ // We matched the extension, so mark this as the end of our path component
270
269
  end = i;
271
270
  }
272
271
  }
273
272
  else {
274
- // Extension does not match, so our result is the entire path
275
- // component
273
+ // Extension does not match, so our result is the entire path component
276
274
  extIdx = -1;
277
275
  end = firstNonSlashEnd;
278
276
  }
@@ -287,16 +285,14 @@ export function basename(path, suffix) {
287
285
  }
288
286
  for (let i = path.length - 1; i >= 0; --i) {
289
287
  if (path[i] === '/') {
290
- // If we reached a path separator that was not part of a set of path
291
- // separators at the end of the string, stop now
288
+ // If we reached a path separator that was not part of a set of path separators at the end of the string, stop now
292
289
  if (!matchedSlash) {
293
290
  start = i + 1;
294
291
  break;
295
292
  }
296
293
  }
297
294
  else if (end === -1) {
298
- // We saw the first non-path separator, mark this as the end of our
299
- // path component
295
+ // We saw the first non-path separator, mark this as the end of our path component
300
296
  matchedSlash = false;
301
297
  end = i + 1;
302
298
  }
@@ -1,11 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- /// <reference types="node" resolution-mode="require"/>
4
- /// <reference types="node" resolution-mode="require"/>
5
- /// <reference types="node" resolution-mode="require"/>
6
- /// <reference types="node" resolution-mode="require"/>
7
- /// <reference types="node" resolution-mode="require"/>
8
- /// <reference types="node" resolution-mode="require"/>
9
1
  import { Buffer } from 'buffer';
10
2
  import type * as fs from 'node:fs';
11
3
  import type * as promises from 'node:fs/promises';
@@ -50,9 +42,9 @@ export declare class FileHandle implements promises.FileHandle {
50
42
  sync(): Promise<void>;
51
43
  /**
52
44
  * Asynchronous ftruncate(2) - Truncate a file to a specified length.
53
- * @param len If not specified, defaults to `0`.
45
+ * @param length If not specified, defaults to `0`.
54
46
  */
55
- truncate(len?: number | null): Promise<void>;
47
+ truncate(length?: number | null): Promise<void>;
56
48
  /**
57
49
  * Asynchronously change file timestamps of the file.
58
50
  * @param atime The last access time. If a string is provided, it will be coerced to number.
@@ -64,10 +56,9 @@ export declare class FileHandle implements promises.FileHandle {
64
56
  * The `FileHandle` must have been opened for appending.
65
57
  * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
66
58
  * @param _options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
67
- * If `encoding` is not supplied, the default of `'utf8'` is used.
68
- * If `mode` is not supplied, the default of `0o666` is used.
69
- * If `mode` is a string, it is parsed as an octal integer.
70
- * If `flag` is not supplied, the default of `'a'` is used.
59
+ * - `encoding` defaults to `'utf8'`.
60
+ * - `mode` defaults to `0o666`.
61
+ * - `flag` defaults to `'a'`.
71
62
  */
72
63
  appendFile(data: string | Uint8Array, _options?: (fs.ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding): Promise<void>;
73
64
  /**
@@ -92,10 +83,11 @@ export declare class FileHandle implements promises.FileHandle {
92
83
  /**
93
84
  * Returns a `ReadableStream` that may be used to read the files data.
94
85
  *
95
- * An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed
96
- * or closing.
86
+ * An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed or closing.
97
87
  *
98
- * 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.
88
+ * While the `ReadableStream` will read the file to completion,
89
+ * it will not close the `FileHandle` automatically.
90
+ * User code must still call the `fileHandle.close()` method.
99
91
  *
100
92
  * @since v17.0.0
101
93
  * @experimental
@@ -134,10 +126,9 @@ export declare class FileHandle implements promises.FileHandle {
134
126
  * It is unsafe to call `writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected).
135
127
  * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
136
128
  * @param _options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
137
- * If `encoding` is not supplied, the default of `'utf8'` is used.
138
- * If `mode` is not supplied, the default of `0o666` is used.
139
- * If `mode` is a string, it is parsed as an octal integer.
140
- * If `flag` is not supplied, the default of `'w'` is used.
129
+ * - `encoding` defaults to `'utf8'`.
130
+ * - `mode` defaults to `0o666`.
131
+ * - `flag` defaults to `'w'`.
141
132
  */
142
133
  writeFile(data: string | Uint8Array, _options?: fs.WriteFileOptions): Promise<void>;
143
134
  /**
@@ -159,36 +150,21 @@ export declare class FileHandle implements promises.FileHandle {
159
150
  */
160
151
  readv(buffers: NodeJS.ArrayBufferView[], position?: number): Promise<fs.ReadVResult>;
161
152
  /**
162
- * Creates a `ReadStream` for reading from the file.
163
- *
153
+ * Creates a stream for reading from the file.
164
154
  * @param options Options for the readable stream
165
- * @returns A `ReadStream` object.
166
155
  */
167
156
  createReadStream(options?: CreateReadStreamOptions): ReadStream;
168
157
  /**
169
- * Creates a `WriteStream` for writing to the file.
170
- *
158
+ * Creates a stream for writing to the file.
171
159
  * @param options Options for the writeable stream.
172
- * @returns A `WriteStream` object
173
160
  */
174
161
  createWriteStream(options?: CreateWriteStreamOptions): WriteStream;
175
162
  }
176
- /**
177
- * Renames a file
178
- * @param oldPath
179
- * @param newPath
180
- */
181
163
  export declare function rename(oldPath: fs.PathLike, newPath: fs.PathLike): Promise<void>;
182
164
  /**
183
- * Test whether or not the given path exists by checking with the file system.
184
- * @param path
165
+ * Test whether or not `path` exists by checking with the file system.
185
166
  */
186
167
  export declare function exists(path: fs.PathLike): Promise<boolean>;
187
- /**
188
- * `stat`.
189
- * @param path
190
- * @returns Stats
191
- */
192
168
  export declare function stat(path: fs.PathLike, options: fs.BigIntOptions): Promise<BigIntStats>;
193
169
  export declare function stat(path: fs.PathLike, options?: {
194
170
  bigint?: false;
@@ -198,8 +174,6 @@ export declare function stat(path: fs.PathLike, options?: fs.StatOptions): Promi
198
174
  * `lstat`.
199
175
  * `lstat()` is identical to `stat()`, except that if path is a symbolic link,
200
176
  * then the link itself is stat-ed, not the file that it refers to.
201
- * @param path
202
- * @return
203
177
  */
204
178
  export declare function lstat(path: fs.PathLike, options?: {
205
179
  bigint?: boolean;
@@ -207,31 +181,20 @@ export declare function lstat(path: fs.PathLike, options?: {
207
181
  export declare function lstat(path: fs.PathLike, options: {
208
182
  bigint: true;
209
183
  }): Promise<BigIntStats>;
210
- /**
211
- * `truncate`.
212
- * @param path
213
- * @param len
214
- */
215
184
  export declare function truncate(path: fs.PathLike, len?: number): Promise<void>;
216
- /**
217
- * `unlink`.
218
- * @param path
219
- */
220
185
  export declare function unlink(path: fs.PathLike): Promise<void>;
221
186
  /**
222
187
  * Asynchronous file open.
223
188
  * @see http://www.manpagez.com/man/2/open/
224
- * @param flags Handles the complexity of the various file modes. See its API for more details.
189
+ * @param flag Handles the complexity of the various file modes. See its API for more details.
225
190
  * @param mode Mode to use to open the file. Can be ignored if the filesystem doesn't support permissions.
226
191
  */
227
192
  export declare function open(path: fs.PathLike, flag?: fs.OpenMode, mode?: fs.Mode): Promise<FileHandle>;
228
193
  /**
229
194
  * Asynchronously reads the entire contents of a file.
230
- * @param filename
231
- * @param options
232
- * options.encoding The string encoding for the file contents. Defaults to `null`.
233
- * options.flag Defaults to `'r'`.
234
- * @returns file data
195
+ * @option encoding The string encoding for the file contents. Defaults to `null`.
196
+ * @option flag Defaults to `'r'`.
197
+ * @returns the file data
235
198
  */
236
199
  export declare function readFile(path: fs.PathLike | promises.FileHandle, options?: {
237
200
  encoding?: null;
@@ -248,12 +211,9 @@ export declare function readFile(path: fs.PathLike | promises.FileHandle, option
248
211
  * Asynchronously writes data to a file, replacing the file if it already exists.
249
212
  *
250
213
  * The encoding option is ignored if data is a buffer.
251
- * @param path
252
- * @param data Note:
253
- * @param _options
254
- * @option options encoding Defaults to `'utf8'`.
255
- * @option options mode Defaults to `0644`.
256
- * @option options flag Defaults to `'w'`.
214
+ * @option encoding Defaults to `'utf8'`.
215
+ * @option mode Defaults to `0644`.
216
+ * @option flag Defaults to `'w'`.
257
217
  */
258
218
  export declare function writeFile(path: fs.PathLike | promises.FileHandle, data: FileContents | Stream | Iterable<string | ArrayBufferView> | AsyncIterable<string | ArrayBufferView>, _options?: (fs.ObjectEncodingOptions & {
259
219
  mode?: fs.Mode;
@@ -261,23 +221,15 @@ export declare function writeFile(path: fs.PathLike | promises.FileHandle, data:
261
221
  flush?: boolean;
262
222
  }) | BufferEncoding | null): Promise<void>;
263
223
  /**
264
- * Asynchronously append data to a file, creating the file if it not yet
265
- * exists.
266
- * @param path
267
- * @param data
268
- * @param options
269
- * @option options encoding Defaults to `'utf8'`.
270
- * @option options mode Defaults to `0644`.
271
- * @option options flag Defaults to `'a'`.
224
+ * Asynchronously append data to a file, creating the file if it not yet exists.
225
+ * @option encoding Defaults to `'utf8'`.
226
+ * @option mode Defaults to `0644`.
227
+ * @option flag Defaults to `'a'`.
272
228
  */
273
229
  export declare function appendFile(path: fs.PathLike | promises.FileHandle, data: FileContents, _options?: BufferEncoding | (fs.EncodingOption & {
274
230
  mode?: fs.Mode;
275
231
  flag?: fs.OpenMode;
276
232
  }) | null): Promise<void>;
277
- /**
278
- * `rmdir`.
279
- * @param path
280
- */
281
233
  export declare function rmdir(path: fs.PathLike): Promise<void>;
282
234
  /**
283
235
  * Asynchronous mkdir(2) - create a directory.
@@ -295,7 +247,7 @@ export declare function mkdir(path: fs.PathLike, options?: fs.Mode | fs.MakeDire
295
247
  /**
296
248
  * Asynchronous readdir(3) - read a directory.
297
249
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
298
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
250
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'`.
299
251
  */
300
252
  export declare function readdir(path: fs.PathLike, options?: (fs.ObjectEncodingOptions & {
301
253
  withFileTypes?: false;
@@ -313,11 +265,6 @@ export declare function readdir(path: fs.PathLike, options: fs.ObjectEncodingOpt
313
265
  withFileTypes: true;
314
266
  recursive?: boolean;
315
267
  }): Promise<Dirent[]>;
316
- /**
317
- * `link`.
318
- * @param targetPath
319
- * @param linkPath
320
- */
321
268
  export declare function link(targetPath: fs.PathLike, linkPath: fs.PathLike): Promise<void>;
322
269
  /**
323
270
  * `symlink`.
@@ -326,68 +273,31 @@ export declare function link(targetPath: fs.PathLike, linkPath: fs.PathLike): Pr
326
273
  * @param type can be either `'dir'` or `'file'` (default is `'file'`)
327
274
  */
328
275
  export declare function symlink(target: fs.PathLike, path: fs.PathLike, type?: fs.symlink.Type | string | null): Promise<void>;
329
- /**
330
- * readlink.
331
- * @param path
332
- */
333
276
  export declare function readlink(path: fs.PathLike, options: fs.BufferEncodingOption): Promise<Buffer>;
334
277
  export declare function readlink(path: fs.PathLike, options?: fs.EncodingOption | null): Promise<string>;
335
278
  export declare function readlink(path: fs.PathLike, options?: fs.BufferEncodingOption | fs.EncodingOption | string | null): Promise<string | Buffer>;
336
- /**
337
- * `chown`.
338
- * @param path
339
- * @param uid
340
- * @param gid
341
- */
342
279
  export declare function chown(path: fs.PathLike, uid: number, gid: number): Promise<void>;
343
- /**
344
- * `lchown`.
345
- * @param path
346
- * @param uid
347
- * @param gid
348
- */
349
280
  export declare function lchown(path: fs.PathLike, uid: number, gid: number): Promise<void>;
350
- /**
351
- * `chmod`.
352
- * @param path
353
- * @param mode
354
- */
355
281
  export declare function chmod(path: fs.PathLike, mode: fs.Mode): Promise<void>;
356
- /**
357
- * `lchmod`.
358
- * @param path
359
- * @param mode
360
- */
361
282
  export declare function lchmod(path: fs.PathLike, mode: fs.Mode): Promise<void>;
362
283
  /**
363
284
  * Change file timestamps of the file referenced by the supplied path.
364
- * @param path
365
- * @param atime
366
- * @param mtime
367
285
  */
368
286
  export declare function utimes(path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
369
287
  /**
370
288
  * Change file timestamps of the file referenced by the supplied path.
371
- * @param path
372
- * @param atime
373
- * @param mtime
374
289
  */
375
290
  export declare function lutimes(path: fs.PathLike, atime: fs.TimeLike, mtime: fs.TimeLike): Promise<void>;
376
291
  /**
377
292
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
378
293
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
379
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
294
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. Defaults to `'utf8'`.
380
295
  */
381
296
  export declare function realpath(path: fs.PathLike, options: fs.BufferEncodingOption): Promise<Buffer>;
382
297
  export declare function realpath(path: fs.PathLike, options?: fs.EncodingOption | BufferEncoding): Promise<string>;
383
298
  export declare function watch(filename: fs.PathLike, options?: fs.WatchOptions | BufferEncoding): AsyncIterable<FileChangeInfo<string>>;
384
299
  export declare function watch(filename: fs.PathLike, options: fs.WatchOptions | fs.BufferEncodingOption): AsyncIterable<FileChangeInfo<Buffer>>;
385
300
  export declare function watch(filename: fs.PathLike, options?: fs.WatchOptions | string): AsyncIterable<FileChangeInfo<string>> | AsyncIterable<FileChangeInfo<Buffer>>;
386
- /**
387
- * `access`.
388
- * @param path
389
- * @param mode
390
- */
391
301
  export declare function access(path: fs.PathLike, mode?: number): Promise<void>;
392
302
  /**
393
303
  * Asynchronous `rm`. Removes files or directories (recursively).
@@ -425,15 +335,15 @@ export declare function opendir(path: fs.PathLike, options?: fs.OpenDirOptions):
425
335
  * @param opts Options for the copy operation. Currently supports these options from Node.js 'fs.await cp':
426
336
  * * `dereference`: Dereference symbolic links.
427
337
  * * `errorOnExist`: Throw an error if the destination file or directory already exists.
428
- * * `filter`: A function that takes a source and destination path and returns a boolean, indicating whether to copy the given source element.
338
+ * * `filter`: A function that takes a source and destination path and returns a boolean, indicating whether to copy `source` element.
429
339
  * * `force`: Overwrite the destination if it exists, and overwrite existing readonly destination files.
430
340
  * * `preserveTimestamps`: Preserve file timestamps.
431
341
  * * `recursive`: If `true`, copies directories recursively.
432
342
  */
433
343
  export declare function cp(source: fs.PathLike, destination: fs.PathLike, opts?: fs.CopyOptions): Promise<void>;
434
344
  /**
435
- * @since v18.15.0
436
- * @return Fulfills with an {fs.StatFs} for the file system.
345
+ * @since Node v18.15.0
346
+ * @returns Fulfills with an {fs.StatFs} for the file system.
437
347
  */
438
348
  export declare function statfs(path: fs.PathLike, opts?: fs.StatFsOptions & {
439
349
  bigint?: false;
@@ -1,7 +1,7 @@
1
1
  var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
2
  if (value !== null && value !== void 0) {
3
3
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
- var dispose;
4
+ var dispose, inner;
5
5
  if (async) {
6
6
  if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
7
  dispose = value[Symbol.asyncDispose];
@@ -9,8 +9,10 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function
9
9
  if (dispose === void 0) {
10
10
  if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
11
  dispose = value[Symbol.dispose];
12
+ if (async) inner = dispose;
12
13
  }
13
14
  if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
14
16
  env.stack.push({ value: value, dispose: dispose, async: async });
15
17
  }
16
18
  else if (async) {
@@ -96,14 +98,14 @@ export class FileHandle {
96
98
  }
97
99
  /**
98
100
  * Asynchronous ftruncate(2) - Truncate a file to a specified length.
99
- * @param len If not specified, defaults to `0`.
101
+ * @param length If not specified, defaults to `0`.
100
102
  */
101
- async truncate(len) {
102
- len || (len = 0);
103
- if (len < 0) {
103
+ async truncate(length) {
104
+ length || (length = 0);
105
+ if (length < 0) {
104
106
  throw new ErrnoError(Errno.EINVAL);
105
107
  }
106
- await this.file.truncate(len);
108
+ await this.file.truncate(length);
107
109
  emitChange('change', this.file.path);
108
110
  }
109
111
  /**
@@ -120,10 +122,9 @@ export class FileHandle {
120
122
  * The `FileHandle` must have been opened for appending.
121
123
  * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
122
124
  * @param _options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
123
- * If `encoding` is not supplied, the default of `'utf8'` is used.
124
- * If `mode` is not supplied, the default of `0o666` is used.
125
- * If `mode` is a string, it is parsed as an octal integer.
126
- * If `flag` is not supplied, the default of `'a'` is used.
125
+ * - `encoding` defaults to `'utf8'`.
126
+ * - `mode` defaults to `0o666`.
127
+ * - `flag` defaults to `'a'`.
127
128
  */
128
129
  async appendFile(data, _options = {}) {
129
130
  const options = normalizeOptions(_options, 'utf8', 'a', 0o644);
@@ -166,10 +167,11 @@ export class FileHandle {
166
167
  /**
167
168
  * Returns a `ReadableStream` that may be used to read the files data.
168
169
  *
169
- * An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed
170
- * or closing.
170
+ * An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed or closing.
171
171
  *
172
- * 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.
172
+ * While the `ReadableStream` will read the file to completion,
173
+ * it will not close the `FileHandle` automatically.
174
+ * User code must still call the `fileHandle.close()` method.
173
175
  *
174
176
  * @since v17.0.0
175
177
  * @experimental
@@ -245,10 +247,9 @@ export class FileHandle {
245
247
  * It is unsafe to call `writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected).
246
248
  * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
247
249
  * @param _options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
248
- * If `encoding` is not supplied, the default of `'utf8'` is used.
249
- * If `mode` is not supplied, the default of `0o666` is used.
250
- * If `mode` is a string, it is parsed as an octal integer.
251
- * If `flag` is not supplied, the default of `'w'` is used.
250
+ * - `encoding` defaults to `'utf8'`.
251
+ * - `mode` defaults to `0o666`.
252
+ * - `flag` defaults to `'w'`.
252
253
  */
253
254
  async writeFile(data, _options = {}) {
254
255
  const options = normalizeOptions(_options, 'utf8', 'w', 0o644);
@@ -297,10 +298,8 @@ export class FileHandle {
297
298
  return { bytesRead, buffers };
298
299
  }
299
300
  /**
300
- * Creates a `ReadStream` for reading from the file.
301
- *
301
+ * Creates a stream for reading from the file.
302
302
  * @param options Options for the readable stream
303
- * @returns A `ReadStream` object.
304
303
  */
305
304
  createReadStream(options) {
306
305
  const stream = new ReadStream({
@@ -322,10 +321,8 @@ export class FileHandle {
322
321
  return stream;
323
322
  }
324
323
  /**
325
- * Creates a `WriteStream` for writing to the file.
326
- *
324
+ * Creates a stream for writing to the file.
327
325
  * @param options Options for the writeable stream.
328
- * @returns A `WriteStream` object
329
326
  */
330
327
  createWriteStream(options) {
331
328
  const streamOptions = {
@@ -346,11 +343,6 @@ export class FileHandle {
346
343
  return stream;
347
344
  }
348
345
  }
349
- /**
350
- * Renames a file
351
- * @param oldPath
352
- * @param newPath
353
- */
354
346
  export async function rename(oldPath, newPath) {
355
347
  oldPath = normalizePath(oldPath);
356
348
  newPath = normalizePath(newPath);
@@ -375,8 +367,7 @@ export async function rename(oldPath, newPath) {
375
367
  }
376
368
  rename;
377
369
  /**
378
- * Test whether or not the given path exists by checking with the file system.
379
- * @param path
370
+ * Test whether or not `path` exists by checking with the file system.
380
371
  */
381
372
  export async function exists(path) {
382
373
  try {
@@ -418,11 +409,6 @@ export async function lstat(path, options) {
418
409
  }
419
410
  lstat;
420
411
  // FILE-ONLY METHODS
421
- /**
422
- * `truncate`.
423
- * @param path
424
- * @param len
425
- */
426
412
  export async function truncate(path, len = 0) {
427
413
  const env_1 = { stack: [], error: void 0, hasError: false };
428
414
  try {
@@ -440,10 +426,6 @@ export async function truncate(path, len = 0) {
440
426
  }
441
427
  }
442
428
  truncate;
443
- /**
444
- * `unlink`.
445
- * @param path
446
- */
447
429
  export async function unlink(path) {
448
430
  path = normalizePath(path);
449
431
  const { fs, path: resolved } = resolveMount(path);
@@ -505,7 +487,7 @@ async function _open(path, _flag, _mode = 0o644, resolveSymlinks) {
505
487
  /**
506
488
  * Asynchronous file open.
507
489
  * @see http://www.manpagez.com/man/2/open/
508
- * @param flags Handles the complexity of the various file modes. See its API for more details.
490
+ * @param flag Handles the complexity of the various file modes. See its API for more details.
509
491
  * @param mode Mode to use to open the file. Can be ignored if the filesystem doesn't support permissions.
510
492
  */
511
493
  export async function open(path, flag = 'r', mode = 0o644) {
@@ -534,12 +516,9 @@ readFile;
534
516
  * Asynchronously writes data to a file, replacing the file if it already exists.
535
517
  *
536
518
  * The encoding option is ignored if data is a buffer.
537
- * @param path
538
- * @param data Note:
539
- * @param _options
540
- * @option options encoding Defaults to `'utf8'`.
541
- * @option options mode Defaults to `0644`.
542
- * @option options flag Defaults to `'w'`.
519
+ * @option encoding Defaults to `'utf8'`.
520
+ * @option mode Defaults to `0644`.
521
+ * @option flag Defaults to `'w'`.
543
522
  */
544
523
  export async function writeFile(path, data, _options) {
545
524
  const env_3 = { stack: [], error: void 0, hasError: false };
@@ -564,14 +543,10 @@ export async function writeFile(path, data, _options) {
564
543
  }
565
544
  writeFile;
566
545
  /**
567
- * Asynchronously append data to a file, creating the file if it not yet
568
- * exists.
569
- * @param path
570
- * @param data
571
- * @param options
572
- * @option options encoding Defaults to `'utf8'`.
573
- * @option options mode Defaults to `0644`.
574
- * @option options flag Defaults to `'a'`.
546
+ * Asynchronously append data to a file, creating the file if it not yet exists.
547
+ * @option encoding Defaults to `'utf8'`.
548
+ * @option mode Defaults to `0644`.
549
+ * @option flag Defaults to `'a'`.
575
550
  */
576
551
  export async function appendFile(path, data, _options) {
577
552
  const env_4 = { stack: [], error: void 0, hasError: false };
@@ -600,10 +575,6 @@ export async function appendFile(path, data, _options) {
600
575
  }
601
576
  appendFile;
602
577
  // DIRECTORY-ONLY METHODS
603
- /**
604
- * `rmdir`.
605
- * @param path
606
- */
607
578
  export async function rmdir(path) {
608
579
  path = normalizePath(path);
609
580
  path = (await exists(path)) ? await realpath(path) : path;
@@ -687,11 +658,6 @@ export async function readdir(path, options) {
687
658
  }
688
659
  readdir;
689
660
  // SYMLINK METHODS
690
- /**
691
- * `link`.
692
- * @param targetPath
693
- * @param linkPath
694
- */
695
661
  export async function link(targetPath, linkPath) {
696
662
  targetPath = normalizePath(targetPath);
697
663
  if (!(await stat(dirname(targetPath))).hasAccess(constants.R_OK)) {
@@ -755,12 +721,6 @@ export async function readlink(path, options) {
755
721
  }
756
722
  readlink;
757
723
  // PROPERTY OPERATIONS
758
- /**
759
- * `chown`.
760
- * @param path
761
- * @param uid
762
- * @param gid
763
- */
764
724
  export async function chown(path, uid, gid) {
765
725
  const env_6 = { stack: [], error: void 0, hasError: false };
766
726
  try {
@@ -778,12 +738,6 @@ export async function chown(path, uid, gid) {
778
738
  }
779
739
  }
780
740
  chown;
781
- /**
782
- * `lchown`.
783
- * @param path
784
- * @param uid
785
- * @param gid
786
- */
787
741
  export async function lchown(path, uid, gid) {
788
742
  const env_7 = { stack: [], error: void 0, hasError: false };
789
743
  try {
@@ -801,11 +755,6 @@ export async function lchown(path, uid, gid) {
801
755
  }
802
756
  }
803
757
  lchown;
804
- /**
805
- * `chmod`.
806
- * @param path
807
- * @param mode
808
- */
809
758
  export async function chmod(path, mode) {
810
759
  const env_8 = { stack: [], error: void 0, hasError: false };
811
760
  try {
@@ -823,11 +772,6 @@ export async function chmod(path, mode) {
823
772
  }
824
773
  }
825
774
  chmod;
826
- /**
827
- * `lchmod`.
828
- * @param path
829
- * @param mode
830
- */
831
775
  export async function lchmod(path, mode) {
832
776
  const env_9 = { stack: [], error: void 0, hasError: false };
833
777
  try {
@@ -847,9 +791,6 @@ export async function lchmod(path, mode) {
847
791
  lchmod;
848
792
  /**
849
793
  * Change file timestamps of the file referenced by the supplied path.
850
- * @param path
851
- * @param atime
852
- * @param mtime
853
794
  */
854
795
  export async function utimes(path, atime, mtime) {
855
796
  const env_10 = { stack: [], error: void 0, hasError: false };
@@ -870,9 +811,6 @@ export async function utimes(path, atime, mtime) {
870
811
  utimes;
871
812
  /**
872
813
  * Change file timestamps of the file referenced by the supplied path.
873
- * @param path
874
- * @param atime
875
- * @param mtime
876
814
  */
877
815
  export async function lutimes(path, atime, mtime) {
878
816
  const env_11 = { stack: [], error: void 0, hasError: false };
@@ -930,11 +868,6 @@ export function watch(filename, options = {}) {
930
868
  };
931
869
  }
932
870
  watch;
933
- /**
934
- * `access`.
935
- * @param path
936
- * @param mode
937
- */
938
871
  export async function access(path, mode = constants.F_OK) {
939
872
  const stats = await stat(path);
940
873
  if (!stats.hasAccess(mode)) {
@@ -1015,7 +948,7 @@ opendir;
1015
948
  * @param opts Options for the copy operation. Currently supports these options from Node.js 'fs.await cp':
1016
949
  * * `dereference`: Dereference symbolic links.
1017
950
  * * `errorOnExist`: Throw an error if the destination file or directory already exists.
1018
- * * `filter`: A function that takes a source and destination path and returns a boolean, indicating whether to copy the given source element.
951
+ * * `filter`: A function that takes a source and destination path and returns a boolean, indicating whether to copy `source` element.
1019
952
  * * `force`: Overwrite the destination if it exists, and overwrite existing readonly destination files.
1020
953
  * * `preserveTimestamps`: Preserve file timestamps.
1021
954
  * * `recursive`: If `true`, copies directories recursively.
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { BigIntStatsFs, StatsFs } from 'node:fs';
3
2
  import type { File } from '../file.js';
4
3
  import type { FileSystem } from '../filesystem.js';
@@ -13,11 +12,11 @@ export type MountObject = Record<AbsolutePath, FileSystem>;
13
12
  */
14
13
  export declare const mounts: Map<string, FileSystem>;
15
14
  /**
16
- * Mounts the file system at the given mount point.
15
+ * Mounts the file system at `mountPoint`.
17
16
  */
18
17
  export declare function mount(mountPoint: string, fs: FileSystem): void;
19
18
  /**
20
- * Unmounts the file system at the given mount point.
19
+ * Unmounts the file system at `mountPoint`.
21
20
  */
22
21
  export declare function umount(mountPoint: string): void;
23
22
  /**
@@ -30,8 +29,13 @@ export declare function resolveMount(path: string): {
30
29
  };
31
30
  /**
32
31
  * Reverse maps the paths in text from the mounted FileSystem to the global path
32
+ * @hidden
33
33
  */
34
34
  export declare function fixPaths(text: string, paths: Record<string, string>): string;
35
+ /**
36
+ * Fix paths in error stacks
37
+ * @hidden
38
+ */
35
39
  export declare function fixError<E extends Error>(e: E, paths: Record<string, string>): E;
36
40
  export declare function mountObject(mounts: MountObject): void;
37
41
  /**