@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
package/dist/file.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  import type { FileReadResult } from 'node:fs/promises';
4
2
  import type { FileSystem } from './filesystem.js';
5
3
  import { Stats, type FileType } from './stats.js';
6
4
  import './polyfills.js';
5
+ /**
6
+ Typescript does not include a type declaration for resizable array buffers.
7
+ It has been standardized into ECMAScript though
8
+ @todo Remove this if TS adds them to lib declarations
9
+ */
7
10
  declare global {
8
11
  interface ArrayBuffer {
9
12
  readonly resizable: boolean;
@@ -41,95 +44,53 @@ export declare abstract class File {
41
44
  * The file system that created the file
42
45
  */
43
46
  fs: FileSystem;
44
- /**
45
- * The path to the file
46
- */
47
47
  readonly path: string;
48
48
  constructor(
49
49
  /**
50
50
  * @internal
51
51
  * The file system that created the file
52
52
  */
53
- fs: FileSystem,
54
- /**
55
- * The path to the file
56
- */
57
- path: string);
53
+ fs: FileSystem, path: string);
58
54
  /**
59
55
  * Get the current file position.
60
56
  */
61
57
  abstract position: number;
62
- /**
63
- * Asynchronous `stat`.
64
- */
65
58
  abstract stat(): Promise<Stats>;
66
- /**
67
- * Synchronous `stat`.
68
- */
69
59
  abstract statSync(): Stats;
70
- /**
71
- * Asynchronous close.
72
- */
73
60
  abstract close(): Promise<void>;
74
- /**
75
- * Synchronous close.
76
- */
77
61
  abstract closeSync(): void;
78
62
  [Symbol.asyncDispose](): Promise<void>;
79
63
  [Symbol.dispose](): void;
80
- /**
81
- * Asynchronous truncate.
82
- */
83
64
  abstract truncate(len: number): Promise<void>;
84
- /**
85
- * Synchronous truncate.
86
- */
87
65
  abstract truncateSync(len: number): void;
88
- /**
89
- * Asynchronous sync.
90
- */
91
66
  abstract sync(): Promise<void>;
92
- /**
93
- * Synchronous sync.
94
- */
95
67
  abstract syncSync(): void;
96
68
  /**
97
69
  * Write buffer to the file.
98
- * Note that it is unsafe to use fs.write multiple times on the same file
99
- * without waiting for the callback.
100
- * @param buffer Uint8Array containing the data to write to
101
- * the file.
70
+ * @param buffer Uint8Array containing the data to write to the file.
102
71
  * @param offset Offset in the buffer to start reading data from.
103
72
  * @param length The amount of bytes to write to the file.
104
- * @param position Offset from the beginning of the file where this
105
- * data should be written. If position is null, the data will be written at
106
- * the current position.
73
+ * @param position Offset from the beginning of the file where this data should be written.
74
+ * If position is null, the data will be written at the current position.
107
75
  * @returns Promise resolving to the new length of the buffer
108
76
  */
109
77
  abstract write(buffer: Uint8Array, offset?: number, length?: number, position?: number): Promise<number>;
110
78
  /**
111
79
  * Write buffer to the file.
112
- * Note that it is unsafe to use fs.writeSync multiple times on the same file
113
- * without waiting for it to return.
114
- * @param buffer Uint8Array containing the data to write to
115
- * the file.
80
+ * @param buffer Uint8Array containing the data to write to the file.
116
81
  * @param offset Offset in the buffer to start reading data from.
117
82
  * @param length The amount of bytes to write to the file.
118
- * @param position Offset from the beginning of the file where this
119
- * data should be written. If position is null, the data will be written at
120
- * the current position.
83
+ * @param position Offset from the beginning of the file where this data should be written.
84
+ * If position is null, the data will be written at the current position.
121
85
  */
122
86
  abstract writeSync(buffer: Uint8Array, offset?: number, length?: number, position?: number): number;
123
87
  /**
124
88
  * Read data from the file.
125
- * @param buffer The buffer that the data will be
126
- * written to.
127
- * @param offset The offset within the buffer where writing will
128
- * start.
89
+ * @param buffer The buffer that the data will be written to.
90
+ * @param offset The offset within the buffer where writing will start.
129
91
  * @param length An integer specifying the number of bytes to read.
130
- * @param position An integer specifying where to begin reading from
131
- * in the file. If position is null, data will be read from the current file
132
- * position.
92
+ * @param position An integer specifying where to begin reading from in the file.
93
+ * If position is null, data will be read from the current file position.
133
94
  * @returns Promise resolving to the new length of the buffer
134
95
  */
135
96
  abstract read<TBuffer extends NodeJS.ArrayBufferView>(buffer: TBuffer, offset?: number, length?: number, position?: number): Promise<FileReadResult<TBuffer>>;
@@ -138,38 +99,21 @@ export declare abstract class File {
138
99
  * @param buffer The buffer that the data will be written to.
139
100
  * @param offset The offset within the buffer where writing will start.
140
101
  * @param length An integer specifying the number of bytes to read.
141
- * @param position An integer specifying where to begin reading from
142
- * in the file. If position is null, data will be read from the current file
143
- * position.
102
+ * @param position An integer specifying where to begin reading from in the file.
103
+ * If position is null, data will be read from the current file position.
144
104
  */
145
105
  abstract readSync(buffer: ArrayBufferView, offset?: number, length?: number, position?: number): number;
146
106
  /**
147
- * Asynchronous `datasync`.
148
- *
149
107
  * Default implementation maps to `sync`.
150
108
  */
151
109
  datasync(): Promise<void>;
152
110
  /**
153
- * Synchronous `datasync`.
154
- *
155
111
  * Default implementation maps to `syncSync`.
156
112
  */
157
113
  datasyncSync(): void;
158
- /**
159
- * Asynchronous `chown`.
160
- */
161
114
  abstract chown(uid: number, gid: number): Promise<void>;
162
- /**
163
- * Synchronous `chown`.
164
- */
165
115
  abstract chownSync(uid: number, gid: number): void;
166
- /**
167
- * Asynchronous `fchmod`.
168
- */
169
116
  abstract chmod(mode: number): Promise<void>;
170
- /**
171
- * Synchronous `fchmod`.
172
- */
173
117
  abstract chmodSync(mode: number): void;
174
118
  /**
175
119
  * Change the file timestamps of the file.
@@ -191,9 +135,8 @@ export declare abstract class File {
191
135
  abstract _setTypeSync(type: FileType): void;
192
136
  }
193
137
  /**
194
- * An implementation of the File interface that operates on a file that is
195
- * completely in-memory. PreloadFiles are backed by a Uint8Array.
196
- *
138
+ * An implementation of `File` that operates completely in-memory.
139
+ * `PreloadFile`s are backed by a `Uint8Array`.
197
140
  */
198
141
  export declare class PreloadFile<FS extends FileSystem> extends File {
199
142
  /**
@@ -203,6 +146,9 @@ export declare class PreloadFile<FS extends FileSystem> extends File {
203
146
  fs: FS;
204
147
  readonly flag: string;
205
148
  readonly stats: Stats;
149
+ /**
150
+ * A buffer containing the entire contents of the file.
151
+ */
206
152
  protected _buffer: Uint8Array;
207
153
  /**
208
154
  * Current position
@@ -217,23 +163,19 @@ export declare class PreloadFile<FS extends FileSystem> extends File {
217
163
  */
218
164
  protected closed: boolean;
219
165
  /**
220
- * Creates a file with the given path and, optionally, the given contents. Note
221
- * that, if contents is specified, it will be mutated by the file!
222
- * @param _mode The mode that the file was opened using.
223
- * Dictates permissions and where the file pointer starts.
224
- * @param stats The stats object for the given file.
225
- * PreloadFile will mutate this object. Note that this object must contain
226
- * the appropriate mode that the file was opened as.
227
- * @param buffer A buffer containing the entire
228
- * contents of the file. PreloadFile will mutate this buffer. If not
229
- * specified, we assume it is a new file.
166
+ * Creates a file with `path` and, optionally, the given contents.
167
+ * Note that, if contents is specified, it will be mutated by the file.
230
168
  */
231
169
  constructor(
232
170
  /**
233
171
  * The file system that created the file.
234
172
  * @internal
235
173
  */
236
- fs: FS, path: string, flag: string, stats: Stats, _buffer?: Uint8Array);
174
+ fs: FS, path: string, flag: string, stats: Stats,
175
+ /**
176
+ * A buffer containing the entire contents of the file.
177
+ */
178
+ _buffer?: Uint8Array);
237
179
  /**
238
180
  * Get the underlying buffer for this file. Mutating not recommended and will mess up dirty tracking.
239
181
  */
@@ -242,84 +184,54 @@ export declare class PreloadFile<FS extends FileSystem> extends File {
242
184
  * Get the current file position.
243
185
  *
244
186
  * We emulate the following bug mentioned in the Node documentation:
245
- * > On Linux, positional writes don't work when the file is opened in append
246
- * mode. The kernel ignores the position argument and always appends the data
247
- * to the end of the file.
248
- * @return The current file position.
187
+ *
188
+ * On Linux, positional writes don't work when the file is opened in append mode.
189
+ * The kernel ignores the position argument and always appends the data to the end of the file.
190
+ * @returns The current file position.
249
191
  */
250
192
  get position(): number;
251
- /**
252
- * Set the file position.
253
- * @param newPos new position
254
- */
255
- set position(newPos: number);
193
+ set position(value: number);
256
194
  sync(): Promise<void>;
257
195
  syncSync(): void;
258
196
  close(): Promise<void>;
259
197
  closeSync(): void;
260
198
  /**
261
- * Cleans up
262
- * This will *not* sync the file data to the FS
199
+ * Cleans up. This will *not* sync the file data to the FS
263
200
  */
264
201
  protected dispose(force?: boolean): void;
265
- /**
266
- * Asynchronous `stat`.
267
- */
268
202
  stat(): Promise<Stats>;
269
- /**
270
- * Synchronous `stat`.
271
- */
272
203
  statSync(): Stats;
273
204
  protected _truncate(length: number): void;
274
- /**
275
- * Asynchronous truncate.
276
- * @param length
277
- */
278
205
  truncate(length: number): Promise<void>;
279
- /**
280
- * Synchronous truncate.
281
- * @param length
282
- */
283
206
  truncateSync(length: number): void;
284
207
  protected _write(buffer: Uint8Array, offset?: number, length?: number, position?: number): number;
285
208
  /**
286
209
  * Write buffer to the file.
287
- * Note that it is unsafe to use fs.write multiple times on the same file
288
- * without waiting for the callback.
289
- * @param buffer Uint8Array containing the data to write to
290
- * the file.
210
+ * @param buffer Uint8Array containing the data to write to the file.
291
211
  * @param offset Offset in the buffer to start reading data from.
292
212
  * @param length The amount of bytes to write to the file.
293
- * @param position Offset from the beginning of the file where this
294
- * data should be written. If position is null, the data will be written at
295
- * the current position.
213
+ * @param position Offset from the beginning of the file where this data should be written.
214
+ * If position is null, the data will be written at the current position.
296
215
  */
297
216
  write(buffer: Uint8Array, offset?: number, length?: number, position?: number): Promise<number>;
298
217
  /**
299
218
  * Write buffer to the file.
300
- * Note that it is unsafe to use fs.writeSync multiple times on the same file
301
- * without waiting for the callback.
302
- * @param buffer Uint8Array containing the data to write to
303
- * the file.
219
+ * @param buffer Uint8Array containing the data to write to the file.
304
220
  * @param offset Offset in the buffer to start reading data from.
305
221
  * @param length The amount of bytes to write to the file.
306
- * @param position Offset from the beginning of the file where this
307
- * data should be written. If position is null, the data will be written at
308
- * the current position.
222
+ * @param position Offset from the beginning of the file where this data should be written.
223
+ * If position is null, the data will be written at the current position.
309
224
  * @returns bytes written
310
225
  */
311
226
  writeSync(buffer: Uint8Array, offset?: number, length?: number, position?: number): number;
312
227
  protected _read(buffer: ArrayBufferView, offset?: number, length?: number, position?: number): number;
313
228
  /**
314
229
  * Read data from the file.
315
- * @param buffer The buffer that the data will be
316
- * written to.
317
- * @param offset The offset within the buffer where writing will
318
- * start.
230
+ * @param buffer The buffer that the data will be written to.
231
+ * @param offset The offset within the buffer where writing will start.
319
232
  * @param length An integer specifying the number of bytes to read.
320
- * @param position An integer specifying where to begin reading from
321
- * in the file. If position is null, data will be read from the current file
322
- * position.
233
+ * @param position An integer specifying where to begin reading from in the file.
234
+ * If position is null, data will be read from the current file position.
323
235
  */
324
236
  read<TBuffer extends ArrayBufferView>(buffer: TBuffer, offset?: number, length?: number, position?: number): Promise<{
325
237
  bytesRead: number;
@@ -327,37 +239,17 @@ export declare class PreloadFile<FS extends FileSystem> extends File {
327
239
  }>;
328
240
  /**
329
241
  * Read data from the file.
330
- * @param buffer The buffer that the data will be
331
- * written to.
242
+ * @param buffer The buffer that the data will be written to.
332
243
  * @param offset The offset within the buffer where writing will start.
333
244
  * @param length An integer specifying the number of bytes to read.
334
- * @param position An integer specifying where to begin reading from
335
- * in the file. If position is null, data will be read from the current file
336
- * position.
245
+ * @param position An integer specifying where to begin reading from in the file.
246
+ * If position is null, data will be read from the current file position.
337
247
  * @returns number of bytes written
338
248
  */
339
249
  readSync(buffer: ArrayBufferView, offset?: number, length?: number, position?: number): number;
340
- /**
341
- * Asynchronous `fchmod`.
342
- * @param mode the mode
343
- */
344
250
  chmod(mode: number): Promise<void>;
345
- /**
346
- * Synchronous `fchmod`.
347
- * @param mode
348
- */
349
251
  chmodSync(mode: number): void;
350
- /**
351
- * Asynchronous `fchown`.
352
- * @param uid
353
- * @param gid
354
- */
355
252
  chown(uid: number, gid: number): Promise<void>;
356
- /**
357
- * Synchronous `fchown`.
358
- * @param uid
359
- * @param gid
360
- */
361
253
  chownSync(uid: number, gid: number): void;
362
254
  utimes(atime: Date, mtime: Date): Promise<void>;
363
255
  utimesSync(atime: Date, mtime: Date): void;
@@ -367,24 +259,11 @@ export declare class PreloadFile<FS extends FileSystem> extends File {
367
259
  [Symbol.dispose](): void;
368
260
  }
369
261
  /**
370
- * For the filesystems which do not sync to anything..
262
+ * For the file systems which do not sync to anything.
371
263
  */
372
264
  export declare class NoSyncFile<T extends FileSystem> extends PreloadFile<T> {
373
- constructor(fs: T, path: string, flag: string, stats: Stats, contents?: Uint8Array);
374
- /**
375
- * Asynchronous sync. Doesn't do anything, simply calls the cb.
376
- */
377
265
  sync(): Promise<void>;
378
- /**
379
- * Synchronous sync. Doesn't do anything.
380
- */
381
266
  syncSync(): void;
382
- /**
383
- * Asynchronous close. Doesn't do anything, simply calls the cb.
384
- */
385
267
  close(): Promise<void>;
386
- /**
387
- * Synchronous close. Doesn't do anything.
388
- */
389
268
  closeSync(): void;
390
269
  }
package/dist/file.js CHANGED
@@ -110,11 +110,7 @@ export class File {
110
110
  * @internal
111
111
  * The file system that created the file
112
112
  */
113
- fs,
114
- /**
115
- * The path to the file
116
- */
117
- path) {
113
+ fs, path) {
118
114
  this.fs = fs;
119
115
  this.path = path;
120
116
  }
@@ -125,16 +121,12 @@ export class File {
125
121
  return this.closeSync();
126
122
  }
127
123
  /**
128
- * Asynchronous `datasync`.
129
- *
130
124
  * Default implementation maps to `sync`.
131
125
  */
132
126
  datasync() {
133
127
  return this.sync();
134
128
  }
135
129
  /**
136
- * Synchronous `datasync`.
137
- *
138
130
  * Default implementation maps to `syncSync`.
139
131
  */
140
132
  datasyncSync() {
@@ -142,29 +134,24 @@ export class File {
142
134
  }
143
135
  }
144
136
  /**
145
- * An implementation of the File interface that operates on a file that is
146
- * completely in-memory. PreloadFiles are backed by a Uint8Array.
147
- *
137
+ * An implementation of `File` that operates completely in-memory.
138
+ * `PreloadFile`s are backed by a `Uint8Array`.
148
139
  */
149
140
  export class PreloadFile extends File {
150
141
  /**
151
- * Creates a file with the given path and, optionally, the given contents. Note
152
- * that, if contents is specified, it will be mutated by the file!
153
- * @param _mode The mode that the file was opened using.
154
- * Dictates permissions and where the file pointer starts.
155
- * @param stats The stats object for the given file.
156
- * PreloadFile will mutate this object. Note that this object must contain
157
- * the appropriate mode that the file was opened as.
158
- * @param buffer A buffer containing the entire
159
- * contents of the file. PreloadFile will mutate this buffer. If not
160
- * specified, we assume it is a new file.
142
+ * Creates a file with `path` and, optionally, the given contents.
143
+ * Note that, if contents is specified, it will be mutated by the file.
161
144
  */
162
145
  constructor(
163
146
  /**
164
147
  * The file system that created the file.
165
148
  * @internal
166
149
  */
167
- fs, path, flag, stats, _buffer = new Uint8Array(new ArrayBuffer(0, fs.metadata().noResizableBuffers ? {} : { maxByteLength: size_max }))) {
150
+ fs, path, flag, stats,
151
+ /**
152
+ * A buffer containing the entire contents of the file.
153
+ */
154
+ _buffer = new Uint8Array(new ArrayBuffer(0, fs.metadata().noResizableBuffers ? {} : { maxByteLength: size_max }))) {
168
155
  super(fs, path);
169
156
  this.fs = fs;
170
157
  this.flag = flag;
@@ -205,10 +192,10 @@ export class PreloadFile extends File {
205
192
  * Get the current file position.
206
193
  *
207
194
  * We emulate the following bug mentioned in the Node documentation:
208
- * > On Linux, positional writes don't work when the file is opened in append
209
- * mode. The kernel ignores the position argument and always appends the data
210
- * to the end of the file.
211
- * @return The current file position.
195
+ *
196
+ * On Linux, positional writes don't work when the file is opened in append mode.
197
+ * The kernel ignores the position argument and always appends the data to the end of the file.
198
+ * @returns The current file position.
212
199
  */
213
200
  get position() {
214
201
  if (isAppendable(this.flag)) {
@@ -216,12 +203,8 @@ export class PreloadFile extends File {
216
203
  }
217
204
  return this._position;
218
205
  }
219
- /**
220
- * Set the file position.
221
- * @param newPos new position
222
- */
223
- set position(newPos) {
224
- this._position = newPos;
206
+ set position(value) {
207
+ this._position = value;
225
208
  }
226
209
  async sync() {
227
210
  if (this.closed) {
@@ -258,8 +241,7 @@ export class PreloadFile extends File {
258
241
  this.dispose();
259
242
  }
260
243
  /**
261
- * Cleans up
262
- * This will *not* sync the file data to the FS
244
+ * Cleans up. This will *not* sync the file data to the FS
263
245
  */
264
246
  dispose(force) {
265
247
  if (this.closed) {
@@ -274,18 +256,12 @@ export class PreloadFile extends File {
274
256
  delete this.stats;
275
257
  this.closed = true;
276
258
  }
277
- /**
278
- * Asynchronous `stat`.
279
- */
280
259
  stat() {
281
260
  if (this.closed) {
282
261
  throw ErrnoError.With('EBADF', this.path, 'File.stat');
283
262
  }
284
263
  return Promise.resolve(new Stats(this.stats));
285
264
  }
286
- /**
287
- * Synchronous `stat`.
288
- */
289
265
  statSync() {
290
266
  if (this.closed) {
291
267
  throw ErrnoError.With('EBADF', this.path, 'File.stat');
@@ -311,18 +287,10 @@ export class PreloadFile extends File {
311
287
  // Truncate.
312
288
  this._buffer = this._buffer.slice(0, length);
313
289
  }
314
- /**
315
- * Asynchronous truncate.
316
- * @param length
317
- */
318
290
  async truncate(length) {
319
291
  this._truncate(length);
320
292
  await this.sync();
321
293
  }
322
- /**
323
- * Synchronous truncate.
324
- * @param length
325
- */
326
294
  truncateSync(length) {
327
295
  this._truncate(length);
328
296
  this.syncSync();
@@ -358,15 +326,11 @@ export class PreloadFile extends File {
358
326
  }
359
327
  /**
360
328
  * Write buffer to the file.
361
- * Note that it is unsafe to use fs.write multiple times on the same file
362
- * without waiting for the callback.
363
- * @param buffer Uint8Array containing the data to write to
364
- * the file.
329
+ * @param buffer Uint8Array containing the data to write to the file.
365
330
  * @param offset Offset in the buffer to start reading data from.
366
331
  * @param length The amount of bytes to write to the file.
367
- * @param position Offset from the beginning of the file where this
368
- * data should be written. If position is null, the data will be written at
369
- * the current position.
332
+ * @param position Offset from the beginning of the file where this data should be written.
333
+ * If position is null, the data will be written at the current position.
370
334
  */
371
335
  async write(buffer, offset, length, position) {
372
336
  const bytesWritten = this._write(buffer, offset, length, position);
@@ -375,15 +339,11 @@ export class PreloadFile extends File {
375
339
  }
376
340
  /**
377
341
  * Write buffer to the file.
378
- * Note that it is unsafe to use fs.writeSync multiple times on the same file
379
- * without waiting for the callback.
380
- * @param buffer Uint8Array containing the data to write to
381
- * the file.
342
+ * @param buffer Uint8Array containing the data to write to the file.
382
343
  * @param offset Offset in the buffer to start reading data from.
383
344
  * @param length The amount of bytes to write to the file.
384
- * @param position Offset from the beginning of the file where this
385
- * data should be written. If position is null, the data will be written at
386
- * the current position.
345
+ * @param position Offset from the beginning of the file where this data should be written.
346
+ * If position is null, the data will be written at the current position.
387
347
  * @returns bytes written
388
348
  */
389
349
  writeSync(buffer, offset = 0, length = this.stats.size, position = this.position) {
@@ -416,14 +376,11 @@ export class PreloadFile extends File {
416
376
  }
417
377
  /**
418
378
  * Read data from the file.
419
- * @param buffer The buffer that the data will be
420
- * written to.
421
- * @param offset The offset within the buffer where writing will
422
- * start.
379
+ * @param buffer The buffer that the data will be written to.
380
+ * @param offset The offset within the buffer where writing will start.
423
381
  * @param length An integer specifying the number of bytes to read.
424
- * @param position An integer specifying where to begin reading from
425
- * in the file. If position is null, data will be read from the current file
426
- * position.
382
+ * @param position An integer specifying where to begin reading from in the file.
383
+ * If position is null, data will be read from the current file position.
427
384
  */
428
385
  async read(buffer, offset, length, position) {
429
386
  const bytesRead = this._read(buffer, offset, length, position);
@@ -432,13 +389,11 @@ export class PreloadFile extends File {
432
389
  }
433
390
  /**
434
391
  * Read data from the file.
435
- * @param buffer The buffer that the data will be
436
- * written to.
392
+ * @param buffer The buffer that the data will be written to.
437
393
  * @param offset The offset within the buffer where writing will start.
438
394
  * @param length An integer specifying the number of bytes to read.
439
- * @param position An integer specifying where to begin reading from
440
- * in the file. If position is null, data will be read from the current file
441
- * position.
395
+ * @param position An integer specifying where to begin reading from in the file.
396
+ * If position is null, data will be read from the current file position.
442
397
  * @returns number of bytes written
443
398
  */
444
399
  readSync(buffer, offset, length, position) {
@@ -446,10 +401,6 @@ export class PreloadFile extends File {
446
401
  this.statSync();
447
402
  return bytesRead;
448
403
  }
449
- /**
450
- * Asynchronous `fchmod`.
451
- * @param mode the mode
452
- */
453
404
  async chmod(mode) {
454
405
  if (this.closed) {
455
406
  throw ErrnoError.With('EBADF', this.path, 'File.chmod');
@@ -458,10 +409,6 @@ export class PreloadFile extends File {
458
409
  this.stats.chmod(mode);
459
410
  await this.sync();
460
411
  }
461
- /**
462
- * Synchronous `fchmod`.
463
- * @param mode
464
- */
465
412
  chmodSync(mode) {
466
413
  if (this.closed) {
467
414
  throw ErrnoError.With('EBADF', this.path, 'File.chmod');
@@ -470,11 +417,6 @@ export class PreloadFile extends File {
470
417
  this.stats.chmod(mode);
471
418
  this.syncSync();
472
419
  }
473
- /**
474
- * Asynchronous `fchown`.
475
- * @param uid
476
- * @param gid
477
- */
478
420
  async chown(uid, gid) {
479
421
  if (this.closed) {
480
422
  throw ErrnoError.With('EBADF', this.path, 'File.chown');
@@ -483,11 +425,6 @@ export class PreloadFile extends File {
483
425
  this.stats.chown(uid, gid);
484
426
  await this.sync();
485
427
  }
486
- /**
487
- * Synchronous `fchown`.
488
- * @param uid
489
- * @param gid
490
- */
491
428
  chownSync(uid, gid) {
492
429
  if (this.closed) {
493
430
  throw ErrnoError.With('EBADF', this.path, 'File.chown');
@@ -538,34 +475,15 @@ export class PreloadFile extends File {
538
475
  }
539
476
  }
540
477
  /**
541
- * For the filesystems which do not sync to anything..
478
+ * For the file systems which do not sync to anything.
542
479
  */
543
480
  export class NoSyncFile extends PreloadFile {
544
- constructor(fs, path, flag, stats, contents) {
545
- super(fs, path, flag, stats, contents);
546
- }
547
- /**
548
- * Asynchronous sync. Doesn't do anything, simply calls the cb.
549
- */
550
481
  sync() {
551
482
  return Promise.resolve();
552
483
  }
553
- /**
554
- * Synchronous sync. Doesn't do anything.
555
- */
556
- syncSync() {
557
- // NOP.
558
- }
559
- /**
560
- * Asynchronous close. Doesn't do anything, simply calls the cb.
561
- */
484
+ syncSync() { }
562
485
  close() {
563
486
  return Promise.resolve();
564
487
  }
565
- /**
566
- * Synchronous close. Doesn't do anything.
567
- */
568
- closeSync() {
569
- // NOP.
570
- }
488
+ closeSync() { }
571
489
  }