@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
@@ -1,8 +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
1
  import { Buffer } from 'buffer';
7
2
  import type * as fs from 'node:fs';
8
3
  import type { FileContents } from '../filesystem.js';
@@ -14,26 +9,15 @@ import * as promises from './promises.js';
14
9
  import { ReadStream, WriteStream } from './streams.js';
15
10
  import { FSWatcher } from './watchers.js';
16
11
  /**
17
- * Asynchronous rename. No arguments other than a possible exception are given
18
- * to the completion callback.
19
- * @param oldPath
20
- * @param newPath
21
- * @param callback
12
+ * Asynchronous rename. No arguments other than a possible exception are given to the completion callback.
22
13
  */
23
14
  export declare function rename(oldPath: fs.PathLike, newPath: fs.PathLike, cb?: Callback): void;
24
15
  /**
25
- * Test whether or not the given path exists by checking with the file system.
16
+ * Test whether or not `path` exists by checking with the file system.
26
17
  * Then call the callback argument with either true or false.
27
- * @param path
28
- * @param callback
29
18
  * @deprecated Use {@link stat} or {@link access} instead.
30
19
  */
31
20
  export declare function exists(path: fs.PathLike, cb?: (exists: boolean) => unknown): void;
32
- /**
33
- * Asynchronous `stat`.
34
- * @param path
35
- * @param callback
36
- */
37
21
  export declare function stat(path: fs.PathLike, callback: Callback<[Stats]>): void;
38
22
  export declare function stat(path: fs.PathLike, options: {
39
23
  bigint?: false;
@@ -46,8 +30,6 @@ export declare function stat(path: fs.PathLike, options: fs.StatOptions, callbac
46
30
  * Asynchronous `lstat`.
47
31
  * `lstat()` is identical to `stat()`, except that if path is a symbolic link,
48
32
  * then the link itself is stat-ed, not the file that it refers to.
49
- * @param path
50
- * @param callback
51
33
  */
52
34
  export declare function lstat(path: fs.PathLike, callback: Callback<[Stats]>): void;
53
35
  export declare function lstat(path: fs.PathLike, options: fs.StatOptions & {
@@ -57,23 +39,13 @@ export declare function lstat(path: fs.PathLike, options: fs.StatOptions & {
57
39
  bigint: true;
58
40
  }, callback: Callback<[BigIntStats]>): void;
59
41
  export declare function lstat(path: fs.PathLike, options: fs.StatOptions, callback: Callback<[Stats | BigIntStats]>): void;
60
- /**
61
- * Asynchronous `truncate`.
62
- * @param path
63
- * @param len
64
- * @param callback
65
- */
66
42
  export declare function truncate(path: fs.PathLike, cb?: Callback): void;
67
43
  export declare function truncate(path: fs.PathLike, len: number, cb?: Callback): void;
68
- /**
69
- * Asynchronous `unlink`.
70
- * @param path
71
- * @param callback
72
- */
73
44
  export declare function unlink(path: fs.PathLike, cb?: Callback): void;
74
45
  /**
75
46
  * Asynchronous file open.
76
47
  * Exclusive mode ensures that path is newly created.
48
+ * Mode defaults to `0644`
77
49
  *
78
50
  * `flags` can be:
79
51
  *
@@ -91,20 +63,14 @@ export declare function unlink(path: fs.PathLike, cb?: Callback): void;
91
63
  * * `'ax+'` - Like 'a+' but opens the file in exclusive mode.
92
64
  *
93
65
  * @see http://www.manpagez.com/man/2/open/
94
- * @param path
95
- * @param flags
96
- * @param mode defaults to `0644`
97
- * @param callback
98
66
  */
99
67
  export declare function open(path: fs.PathLike, flag: string, cb?: Callback<[number]>): void;
100
68
  export declare function open(path: fs.PathLike, flag: string, mode: number | string, cb?: Callback<[number]>): void;
101
69
  /**
102
70
  * Asynchronously reads the entire contents of a file.
103
- * @param filename
104
- * @param options
105
- * @option options encoding The string encoding for the file contents. Defaults to `null`.
106
- * @option options flag Defaults to `'r'`.
107
- * @param callback If no encoding is specified, then the raw buffer is returned.
71
+ * @option encoding The string encoding for the file contents. Defaults to `null`.
72
+ * @option flag Defaults to `'r'`.
73
+ * @param cb If no encoding is specified, then the raw buffer is returned.
108
74
  */
109
75
  export declare function readFile(filename: fs.PathLike, cb: Callback<[Uint8Array]>): void;
110
76
  export declare function readFile(filename: fs.PathLike, options: {
@@ -120,13 +86,9 @@ export declare function readFile(filename: fs.PathLike, options: {
120
86
  *
121
87
  * The encoding option is ignored if data is a buffer.
122
88
  *
123
- * @param filename
124
- * @param data
125
- * @param options
126
89
  * @option encoding Defaults to `'utf8'`.
127
90
  * @option mode Defaults to `0644`.
128
91
  * @option flag Defaults to `'w'`.
129
- * @param callback
130
92
  */
131
93
  export declare function writeFile(filename: fs.PathLike, data: FileContents, cb?: Callback): void;
132
94
  export declare function writeFile(filename: fs.PathLike, data: FileContents, encoding?: BufferEncoding, cb?: Callback): void;
@@ -135,13 +97,9 @@ export declare function writeFile(filename: fs.PathLike, data: FileContents, opt
135
97
  * Asynchronously append data to a file, creating the file if it not yet
136
98
  * exists.
137
99
  *
138
- * @param filename
139
- * @param data
140
- * @param options
141
100
  * @option encoding Defaults to `'utf8'`.
142
101
  * @option mode Defaults to `0644`.
143
102
  * @option flag Defaults to `'a'`.
144
- * @param callback
145
103
  */
146
104
  export declare function appendFile(filename: fs.PathLike, data: FileContents, cb?: Callback): void;
147
105
  export declare function appendFile(filename: fs.PathLike, data: FileContents, options?: fs.EncodingOption & {
@@ -151,10 +109,7 @@ export declare function appendFile(filename: fs.PathLike, data: FileContents, op
151
109
  export declare function appendFile(filename: fs.PathLike, data: FileContents, encoding?: BufferEncoding, cb?: Callback): void;
152
110
  /**
153
111
  * Asynchronous `fstat`.
154
- * `fstat()` is identical to `stat()`, except that the file to be stat-ed is
155
- * specified by the file descriptor `fd`.
156
- * @param fd
157
- * @param callback
112
+ * `fstat()` is identical to `stat()`, except that the file to be stat-ed is specified by the file descriptor `fd`.
158
113
  */
159
114
  export declare function fstat(fd: number, cb: Callback<[Stats]>): void;
160
115
  export declare function fstat(fd: number, options: fs.StatOptions & {
@@ -163,45 +118,20 @@ export declare function fstat(fd: number, options: fs.StatOptions & {
163
118
  export declare function fstat(fd: number, options: fs.StatOptions & {
164
119
  bigint: true;
165
120
  }, cb: Callback<[BigIntStats]>): void;
166
- /**
167
- * Asynchronous close.
168
- * @param fd
169
- * @param callback
170
- */
171
121
  export declare function close(fd: number, cb?: Callback): void;
172
- /**
173
- * Asynchronous ftruncate.
174
- * @param fd
175
- * @param len
176
- * @param callback
177
- */
178
122
  export declare function ftruncate(fd: number, cb?: Callback): void;
179
123
  export declare function ftruncate(fd: number, len?: number, cb?: Callback): void;
180
- /**
181
- * Asynchronous fsync.
182
- * @param fd
183
- * @param callback
184
- */
185
124
  export declare function fsync(fd: number, cb?: Callback): void;
186
- /**
187
- * Asynchronous fdatasync.
188
- * @param fd
189
- * @param callback
190
- */
191
125
  export declare function fdatasync(fd: number, cb?: Callback): void;
192
126
  /**
193
127
  * Write buffer to the file specified by `fd`.
194
- * Note that it is unsafe to use fs.write multiple times on the same file
195
- * without waiting for the callback.
196
- * @param fd
197
- * @param buffer Uint8Array containing the data to write to
198
- * the file.
128
+ * Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback.
129
+ * @param buffer Uint8Array containing the data to write to the file.
199
130
  * @param offset Offset in the buffer to start reading data from.
200
131
  * @param length The amount of bytes to write to the file.
201
- * @param position Offset from the beginning of the file where this
202
- * data should be written. If position is null, the data will be written at
203
- * the current position.
204
- * @param callback The number specifies the number of bytes written into the file.
132
+ * @param position Offset from the beginning of the file where this data should be written.
133
+ * If position is null, the data will be written at the current position.
134
+ * @param cb The number specifies the number of bytes written into the file.
205
135
  */
206
136
  export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, cb?: Callback<[number, Uint8Array]>): void;
207
137
  export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
@@ -210,60 +140,30 @@ export declare function write(fd: number, data: FileContents, position?: number,
210
140
  export declare function write(fd: number, data: FileContents, position: number | null, encoding: BufferEncoding, cb?: Callback<[number, string]>): void;
211
141
  /**
212
142
  * Read data from the file specified by `fd`.
213
- * @param buffer The buffer that the data will be
214
- * written to.
215
- * @param offset The offset within the buffer where writing will
216
- * start.
143
+ * @param buffer The buffer that the data will be written to.
144
+ * @param offset The offset within the buffer where writing will start.
217
145
  * @param length An integer specifying the number of bytes to read.
218
- * @param position An integer specifying where to begin reading from
219
- * in the file. If position is null, data will be read from the current file
220
- * position.
221
- * @param callback The number is the number of bytes read
146
+ * @param position An integer specifying where to begin reading from in the file.
147
+ * If position is null, data will be read from the current file position.
148
+ * @param cb The number is the number of bytes read
222
149
  */
223
150
  export declare function read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
224
- /**
225
- * Asynchronous `fchown`.
226
- * @param fd
227
- * @param uid
228
- * @param gid
229
- * @param callback
230
- */
231
151
  export declare function fchown(fd: number, uid: number, gid: number, cb?: Callback): void;
232
- /**
233
- * Asynchronous `fchmod`.
234
- * @param fd
235
- * @param mode
236
- * @param callback
237
- */
238
152
  export declare function fchmod(fd: number, mode: string | number, cb: Callback): void;
239
153
  /**
240
- * Change the file timestamps of a file referenced by the supplied file
241
- * descriptor.
242
- * @param fd
243
- * @param atime
244
- * @param mtime
245
- * @param callback
154
+ * Change the file timestamps of a file referenced by the supplied file descriptor.
246
155
  */
247
156
  export declare function futimes(fd: number, atime: number | Date, mtime: number | Date, cb?: Callback): void;
248
- /**
249
- * Asynchronous `rmdir`.
250
- * @param path
251
- * @param callback
252
- */
253
157
  export declare function rmdir(path: fs.PathLike, cb?: Callback): void;
254
158
  /**
255
159
  * Asynchronous `mkdir`.
256
- * @param path
257
160
  * @param mode defaults to `0777`
258
- * @param callback
259
161
  */
260
162
  export declare function mkdir(path: fs.PathLike, mode?: fs.Mode, cb?: Callback): void;
261
163
  /**
262
164
  * Asynchronous `readdir`. Reads the contents of a directory.
263
165
  * The callback gets two arguments `(err, files)` where `files` is an array of
264
166
  * the names of the files in the directory excluding `'.'` and `'..'`.
265
- * @param path
266
- * @param callback
267
167
  */
268
168
  export declare function readdir(path: fs.PathLike, cb: Callback<[string[]]>): void;
269
169
  export declare function readdir(path: fs.PathLike, options: {
@@ -272,92 +172,37 @@ export declare function readdir(path: fs.PathLike, options: {
272
172
  export declare function readdir(path: fs.PathLike, options: {
273
173
  withFileTypes: true;
274
174
  }, cb: Callback<[Dirent[]]>): void;
275
- /**
276
- * Asynchronous `link`.
277
- * @param existing
278
- * @param newpath
279
- * @param callback
280
- */
281
175
  export declare function link(existing: fs.PathLike, newpath: fs.PathLike, cb?: Callback): void;
282
176
  /**
283
177
  * Asynchronous `symlink`.
284
178
  * @param target target path
285
179
  * @param path link path
286
- * @param type can be either `'dir'` or `'file'` (default is `'file'`)
287
- * @param callback
180
+ * Type defaults to file
288
181
  */
289
182
  export declare function symlink(target: fs.PathLike, path: fs.PathLike, cb?: Callback): void;
290
183
  export declare function symlink(target: fs.PathLike, path: fs.PathLike, type?: fs.symlink.Type, cb?: Callback): void;
291
- /**
292
- * Asynchronous readlink.
293
- * @param path
294
- * @param callback
295
- */
296
184
  export declare function readlink(path: fs.PathLike, callback: Callback<[string]> & any): void;
297
185
  export declare function readlink(path: fs.PathLike, options: fs.BufferEncodingOption, callback: Callback<[Uint8Array]>): void;
298
186
  export declare function readlink(path: fs.PathLike, options: fs.EncodingOption, callback: Callback<[string | Uint8Array]>): void;
299
187
  export declare function readlink(path: fs.PathLike, options: fs.EncodingOption, callback: Callback<[string]>): void;
300
- /**
301
- * Asynchronous `chown`.
302
- * @param path
303
- * @param uid
304
- * @param gid
305
- * @param callback
306
- */
307
188
  export declare function chown(path: fs.PathLike, uid: number, gid: number, cb?: Callback): void;
308
- /**
309
- * Asynchronous `lchown`.
310
- * @param path
311
- * @param uid
312
- * @param gid
313
- * @param callback
314
- */
315
189
  export declare function lchown(path: fs.PathLike, uid: number, gid: number, cb?: Callback): void;
316
- /**
317
- * Asynchronous `chmod`.
318
- * @param path
319
- * @param mode
320
- * @param callback
321
- */
322
190
  export declare function chmod(path: fs.PathLike, mode: number | string, cb?: Callback): void;
323
- /**
324
- * Asynchronous `lchmod`.
325
- * @param path
326
- * @param mode
327
- * @param callback
328
- */
329
191
  export declare function lchmod(path: fs.PathLike, mode: number | string, cb?: Callback): void;
330
192
  /**
331
193
  * Change file timestamps of the file referenced by the supplied path.
332
- * @param path
333
- * @param atime
334
- * @param mtime
335
- * @param callback
336
194
  */
337
195
  export declare function utimes(path: fs.PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
338
196
  /**
339
197
  * Change file timestamps of the file referenced by the supplied path.
340
- * @param path
341
- * @param atime
342
- * @param mtime
343
- * @param callback
344
198
  */
345
199
  export declare function lutimes(path: fs.PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
346
200
  /**
347
201
  * Asynchronous `realpath`. The callback gets two arguments
348
202
  * `(err, resolvedPath)`. May use `process.cwd` to resolve relative paths.
349
- *
350
- * @param path
351
- * @param callback
352
203
  */
353
204
  export declare function realpath(path: fs.PathLike, cb?: Callback<[string]>): void;
354
205
  export declare function realpath(path: fs.PathLike, options: fs.EncodingOption, cb: Callback<[string]>): void;
355
- /**
356
- * Asynchronous `access`.
357
- * @param path
358
- * @param mode
359
- * @param callback
360
- */
361
206
  export declare function access(path: fs.PathLike, cb: Callback): void;
362
207
  export declare function access(path: fs.PathLike, mode: number, cb: Callback): void;
363
208
  /**
@@ -425,7 +270,7 @@ interface WriteStreamOptions extends StreamOptions {
425
270
  * @param options Options for the ReadStream and file opening (e.g., `encoding`, `highWaterMark`, `mode`).
426
271
  * @returns A ReadStream object for interacting with the file's contents.
427
272
  */
428
- export declare function createReadStream(path: fs.PathLike, _options?: BufferEncoding | ReadStreamOptions): ReadStream;
273
+ export declare function createReadStream(path: fs.PathLike, options?: BufferEncoding | ReadStreamOptions): ReadStream;
429
274
  /**
430
275
  * Opens a file in write mode and creates a Node.js-like WriteStream.
431
276
  *
@@ -433,7 +278,7 @@ export declare function createReadStream(path: fs.PathLike, _options?: BufferEnc
433
278
  * @param options Options for the WriteStream and file opening (e.g., `encoding`, `highWaterMark`, `mode`).
434
279
  * @returns A WriteStream object for writing to the file.
435
280
  */
436
- export declare function createWriteStream(path: fs.PathLike, _options?: BufferEncoding | WriteStreamOptions): WriteStream;
281
+ export declare function createWriteStream(path: fs.PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream;
437
282
  export declare function rm(path: fs.PathLike, callback: Callback): void;
438
283
  export declare function rm(path: fs.PathLike, options: fs.RmOptions, callback: Callback): void;
439
284
  /**
@@ -9,11 +9,7 @@ import { ReadStream, WriteStream } from './streams.js';
9
9
  import { FSWatcher, StatWatcher } from './watchers.js';
10
10
  const nop = () => { };
11
11
  /**
12
- * Asynchronous rename. No arguments other than a possible exception are given
13
- * to the completion callback.
14
- * @param oldPath
15
- * @param newPath
16
- * @param callback
12
+ * Asynchronous rename. No arguments other than a possible exception are given to the completion callback.
17
13
  */
18
14
  export function rename(oldPath, newPath, cb = nop) {
19
15
  promises
@@ -23,10 +19,8 @@ export function rename(oldPath, newPath, cb = nop) {
23
19
  }
24
20
  rename;
25
21
  /**
26
- * Test whether or not the given path exists by checking with the file system.
22
+ * Test whether or not `path` exists by checking with the file system.
27
23
  * Then call the callback argument with either true or false.
28
- * @param path
29
- * @param callback
30
24
  * @deprecated Use {@link stat} or {@link access} instead.
31
25
  */
32
26
  export function exists(path, cb = nop) {
@@ -61,11 +55,6 @@ export function truncate(path, cbLen = 0, cb = nop) {
61
55
  .catch(cb);
62
56
  }
63
57
  truncate;
64
- /**
65
- * Asynchronous `unlink`.
66
- * @param path
67
- * @param callback
68
- */
69
58
  export function unlink(path, cb = nop) {
70
59
  promises
71
60
  .unlink(path)
@@ -115,11 +104,6 @@ export function fstat(fd, options, cb = nop) {
115
104
  .catch(cb);
116
105
  }
117
106
  fstat;
118
- /**
119
- * Asynchronous close.
120
- * @param fd
121
- * @param callback
122
- */
123
107
  export function close(fd, cb = nop) {
124
108
  new promises.FileHandle(fd)
125
109
  .close()
@@ -139,11 +123,6 @@ export function ftruncate(fd, lenOrCB, cb = nop) {
139
123
  .catch(cb);
140
124
  }
141
125
  ftruncate;
142
- /**
143
- * Asynchronous fsync.
144
- * @param fd
145
- * @param callback
146
- */
147
126
  export function fsync(fd, cb = nop) {
148
127
  fd2file(fd)
149
128
  .sync()
@@ -151,11 +130,6 @@ export function fsync(fd, cb = nop) {
151
130
  .catch(cb);
152
131
  }
153
132
  fsync;
154
- /**
155
- * Asynchronous fdatasync.
156
- * @param fd
157
- * @param callback
158
- */
159
133
  export function fdatasync(fd, cb = nop) {
160
134
  fd2file(fd)
161
135
  .datasync()
@@ -211,15 +185,12 @@ export function write(fd, data, cbPosOff, cbLenEnc, cbPosEnc, cb = nop) {
211
185
  write;
212
186
  /**
213
187
  * Read data from the file specified by `fd`.
214
- * @param buffer The buffer that the data will be
215
- * written to.
216
- * @param offset The offset within the buffer where writing will
217
- * start.
188
+ * @param buffer The buffer that the data will be written to.
189
+ * @param offset The offset within the buffer where writing will start.
218
190
  * @param length An integer specifying the number of bytes to read.
219
- * @param position An integer specifying where to begin reading from
220
- * in the file. If position is null, data will be read from the current file
221
- * position.
222
- * @param callback The number is the number of bytes read
191
+ * @param position An integer specifying where to begin reading from in the file.
192
+ * If position is null, data will be read from the current file position.
193
+ * @param cb The number is the number of bytes read
223
194
  */
224
195
  export function read(fd, buffer, offset, length, position, cb = nop) {
225
196
  new promises.FileHandle(fd)
@@ -228,13 +199,6 @@ export function read(fd, buffer, offset, length, position, cb = nop) {
228
199
  .catch(cb);
229
200
  }
230
201
  read;
231
- /**
232
- * Asynchronous `fchown`.
233
- * @param fd
234
- * @param uid
235
- * @param gid
236
- * @param callback
237
- */
238
202
  export function fchown(fd, uid, gid, cb = nop) {
239
203
  new promises.FileHandle(fd)
240
204
  .chown(uid, gid)
@@ -242,12 +206,6 @@ export function fchown(fd, uid, gid, cb = nop) {
242
206
  .catch(cb);
243
207
  }
244
208
  fchown;
245
- /**
246
- * Asynchronous `fchmod`.
247
- * @param fd
248
- * @param mode
249
- * @param callback
250
- */
251
209
  export function fchmod(fd, mode, cb) {
252
210
  new promises.FileHandle(fd)
253
211
  .chmod(mode)
@@ -256,12 +214,7 @@ export function fchmod(fd, mode, cb) {
256
214
  }
257
215
  fchmod;
258
216
  /**
259
- * Change the file timestamps of a file referenced by the supplied file
260
- * descriptor.
261
- * @param fd
262
- * @param atime
263
- * @param mtime
264
- * @param callback
217
+ * Change the file timestamps of a file referenced by the supplied file descriptor.
265
218
  */
266
219
  export function futimes(fd, atime, mtime, cb = nop) {
267
220
  new promises.FileHandle(fd)
@@ -270,11 +223,6 @@ export function futimes(fd, atime, mtime, cb = nop) {
270
223
  .catch(cb);
271
224
  }
272
225
  futimes;
273
- /**
274
- * Asynchronous `rmdir`.
275
- * @param path
276
- * @param callback
277
- */
278
226
  export function rmdir(path, cb = nop) {
279
227
  promises
280
228
  .rmdir(path)
@@ -284,9 +232,7 @@ export function rmdir(path, cb = nop) {
284
232
  rmdir;
285
233
  /**
286
234
  * Asynchronous `mkdir`.
287
- * @param path
288
235
  * @param mode defaults to `0777`
289
- * @param callback
290
236
  */
291
237
  export function mkdir(path, mode, cb = nop) {
292
238
  promises
@@ -304,12 +250,6 @@ export function readdir(path, _options, cb = nop) {
304
250
  .catch(cb);
305
251
  }
306
252
  readdir;
307
- /**
308
- * Asynchronous `link`.
309
- * @param existing
310
- * @param newpath
311
- * @param callback
312
- */
313
253
  export function link(existing, newpath, cb = nop) {
314
254
  promises
315
255
  .link(existing, newpath)
@@ -334,13 +274,6 @@ export function readlink(path, options, callback = nop) {
334
274
  .catch(callback);
335
275
  }
336
276
  readlink;
337
- /**
338
- * Asynchronous `chown`.
339
- * @param path
340
- * @param uid
341
- * @param gid
342
- * @param callback
343
- */
344
277
  export function chown(path, uid, gid, cb = nop) {
345
278
  promises
346
279
  .chown(path, uid, gid)
@@ -348,13 +281,6 @@ export function chown(path, uid, gid, cb = nop) {
348
281
  .catch(cb);
349
282
  }
350
283
  chown;
351
- /**
352
- * Asynchronous `lchown`.
353
- * @param path
354
- * @param uid
355
- * @param gid
356
- * @param callback
357
- */
358
284
  export function lchown(path, uid, gid, cb = nop) {
359
285
  promises
360
286
  .lchown(path, uid, gid)
@@ -362,12 +288,6 @@ export function lchown(path, uid, gid, cb = nop) {
362
288
  .catch(cb);
363
289
  }
364
290
  lchown;
365
- /**
366
- * Asynchronous `chmod`.
367
- * @param path
368
- * @param mode
369
- * @param callback
370
- */
371
291
  export function chmod(path, mode, cb = nop) {
372
292
  promises
373
293
  .chmod(path, mode)
@@ -375,12 +295,6 @@ export function chmod(path, mode, cb = nop) {
375
295
  .catch(cb);
376
296
  }
377
297
  chmod;
378
- /**
379
- * Asynchronous `lchmod`.
380
- * @param path
381
- * @param mode
382
- * @param callback
383
- */
384
298
  export function lchmod(path, mode, cb = nop) {
385
299
  promises
386
300
  .lchmod(path, mode)
@@ -390,10 +304,6 @@ export function lchmod(path, mode, cb = nop) {
390
304
  lchmod;
391
305
  /**
392
306
  * Change file timestamps of the file referenced by the supplied path.
393
- * @param path
394
- * @param atime
395
- * @param mtime
396
- * @param callback
397
307
  */
398
308
  export function utimes(path, atime, mtime, cb = nop) {
399
309
  promises
@@ -404,10 +314,6 @@ export function utimes(path, atime, mtime, cb = nop) {
404
314
  utimes;
405
315
  /**
406
316
  * Change file timestamps of the file referenced by the supplied path.
407
- * @param path
408
- * @param atime
409
- * @param mtime
410
- * @param callback
411
317
  */
412
318
  export function lutimes(path, atime, mtime, cb = nop) {
413
319
  promises
@@ -434,11 +340,11 @@ export function access(path, cbMode, cb = nop) {
434
340
  }
435
341
  access;
436
342
  const statWatchers = new Map();
437
- export function watchFile(path, optsListener, listener) {
343
+ export function watchFile(path, options, listener) {
438
344
  const normalizedPath = normalizePath(path.toString());
439
- const options = typeof optsListener != 'function' ? optsListener : {};
440
- if (typeof optsListener === 'function') {
441
- listener = optsListener;
345
+ const opts = typeof options != 'function' ? options : {};
346
+ if (typeof options == 'function') {
347
+ listener = options;
442
348
  }
443
349
  if (!listener) {
444
350
  throw new ErrnoError(Errno.EINVAL, 'No listener specified', path.toString(), 'watchFile');
@@ -450,7 +356,7 @@ export function watchFile(path, optsListener, listener) {
450
356
  }
451
357
  return;
452
358
  }
453
- const watcher = new StatWatcher(normalizedPath, options);
359
+ const watcher = new StatWatcher(normalizedPath, opts);
454
360
  watcher.on('change', (curr, prev) => {
455
361
  const entry = statWatchers.get(normalizedPath);
456
362
  if (!entry) {
@@ -505,8 +411,8 @@ watch;
505
411
  * @param options Options for the ReadStream and file opening (e.g., `encoding`, `highWaterMark`, `mode`).
506
412
  * @returns A ReadStream object for interacting with the file's contents.
507
413
  */
508
- export function createReadStream(path, _options) {
509
- const options = typeof _options == 'object' ? _options : { encoding: _options };
414
+ export function createReadStream(path, options) {
415
+ options = typeof options == 'object' ? options : { encoding: options };
510
416
  let handle;
511
417
  const stream = new ReadStream({
512
418
  highWaterMark: options.highWaterMark || 64 * 1024,
@@ -544,8 +450,8 @@ createReadStream;
544
450
  * @param options Options for the WriteStream and file opening (e.g., `encoding`, `highWaterMark`, `mode`).
545
451
  * @returns A WriteStream object for writing to the file.
546
452
  */
547
- export function createWriteStream(path, _options) {
548
- const options = typeof _options == 'object' ? _options : { encoding: _options };
453
+ export function createWriteStream(path, options) {
454
+ options = typeof options == 'object' ? options : { encoding: options };
549
455
  let handle;
550
456
  const stream = new WriteStream({
551
457
  highWaterMark: options?.highWaterMark,
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { Dir as _Dir, Dirent as _Dirent } from 'fs';
3
2
  import type { Stats } from '../stats.js';
4
3
  import type { Callback } from '../utils.js';
@@ -1,8 +1,4 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { ParsedPath } from 'node:path';
3
- /**
4
- * An absolute path
5
- */
6
2
  export type AbsolutePath = `/${string}`;
7
3
  export declare let cwd: string;
8
4
  export declare function cd(path: string): void;