@zenfs/core 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/ApiError.d.ts +51 -14
  2. package/dist/ApiError.js +60 -34
  3. package/dist/FileIndex.d.ts +32 -35
  4. package/dist/FileIndex.js +93 -109
  5. package/dist/backends/AsyncMirror.d.ts +42 -43
  6. package/dist/backends/AsyncMirror.js +146 -133
  7. package/dist/backends/AsyncStore.d.ts +29 -28
  8. package/dist/backends/AsyncStore.js +139 -189
  9. package/dist/backends/InMemory.d.ts +16 -13
  10. package/dist/backends/InMemory.js +29 -14
  11. package/dist/backends/Locked.d.ts +8 -28
  12. package/dist/backends/Locked.js +44 -148
  13. package/dist/backends/OverlayFS.d.ts +26 -34
  14. package/dist/backends/OverlayFS.js +208 -371
  15. package/dist/backends/SyncStore.d.ts +54 -72
  16. package/dist/backends/SyncStore.js +159 -161
  17. package/dist/backends/backend.d.ts +45 -29
  18. package/dist/backends/backend.js +83 -13
  19. package/dist/backends/index.d.ts +6 -7
  20. package/dist/backends/index.js +5 -6
  21. package/dist/browser.min.js +5 -7
  22. package/dist/browser.min.js.map +4 -4
  23. package/dist/emulation/callbacks.d.ts +36 -67
  24. package/dist/emulation/callbacks.js +90 -46
  25. package/dist/emulation/constants.js +1 -1
  26. package/dist/emulation/promises.d.ts +228 -129
  27. package/dist/emulation/promises.js +414 -172
  28. package/dist/emulation/shared.d.ts +10 -10
  29. package/dist/emulation/shared.js +18 -20
  30. package/dist/emulation/sync.d.ts +25 -25
  31. package/dist/emulation/sync.js +187 -73
  32. package/dist/file.d.ts +166 -170
  33. package/dist/file.js +199 -218
  34. package/dist/filesystem.d.ts +68 -241
  35. package/dist/filesystem.js +59 -383
  36. package/dist/index.d.ts +7 -44
  37. package/dist/index.js +13 -52
  38. package/dist/inode.d.ts +37 -28
  39. package/dist/inode.js +123 -65
  40. package/dist/stats.d.ts +21 -19
  41. package/dist/stats.js +35 -56
  42. package/dist/utils.d.ts +26 -9
  43. package/dist/utils.js +73 -102
  44. package/package.json +4 -3
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="node" resolution-mode="require"/>
3
- import type { BaseEncodingOptions, BufferEncodingOption, FSWatcher, StatOptions, symlink as _symlink } from 'fs';
3
+ import type * as Node from 'fs';
4
4
  import { TwoArgCallback, NoArgCallback, ThreeArgCallback, FileContents } from '../filesystem.js';
5
5
  import { BigIntStats, Stats } from '../stats.js';
6
6
  import { PathLike } from './shared.js';
@@ -17,10 +17,6 @@ export declare function rename(oldPath: PathLike, newPath: PathLike, cb?: NoArgC
17
17
  /**
18
18
  * Test whether or not the given path exists by checking with the file system.
19
19
  * Then call the callback argument with either true or false.
20
- * @example Sample invocation
21
- * fs.exists('/etc/passwd', function (exists) {
22
- * util.debug(exists ? "it's there" : "no passwd!");
23
- * });
24
20
  * @param path
25
21
  * @param callback
26
22
  */
@@ -31,13 +27,13 @@ export declare function exists(path: PathLike, cb?: (exists: boolean) => unknown
31
27
  * @param callback
32
28
  */
33
29
  export declare function stat(path: PathLike, callback: TwoArgCallback<Stats>): void;
34
- export declare function stat(path: PathLike, options: StatOptions & {
30
+ export declare function stat(path: PathLike, options: Node.StatOptions & {
35
31
  bigint?: false;
36
32
  }, callback: TwoArgCallback<Stats>): void;
37
- export declare function stat(path: PathLike, options: StatOptions & {
33
+ export declare function stat(path: PathLike, options: Node.StatOptions & {
38
34
  bigint: true;
39
35
  }, callback: TwoArgCallback<BigIntStats>): void;
40
- export declare function stat(path: PathLike, options: StatOptions, callback: TwoArgCallback<Stats | BigIntStats>): void;
36
+ export declare function stat(path: PathLike, options: Node.StatOptions, callback: TwoArgCallback<Stats | BigIntStats>): void;
41
37
  /**
42
38
  * Asynchronous `lstat`.
43
39
  * `lstat()` is identical to `stat()`, except that if path is a symbolic link,
@@ -46,13 +42,13 @@ export declare function stat(path: PathLike, options: StatOptions, callback: Two
46
42
  * @param callback
47
43
  */
48
44
  export declare function lstat(path: PathLike, callback: TwoArgCallback<Stats>): void;
49
- export declare function lstat(path: PathLike, options: StatOptions & {
45
+ export declare function lstat(path: PathLike, options: Node.StatOptions & {
50
46
  bigint?: false;
51
47
  }, callback: TwoArgCallback<Stats>): void;
52
- export declare function lstat(path: PathLike, options: StatOptions & {
48
+ export declare function lstat(path: PathLike, options: Node.StatOptions & {
53
49
  bigint: true;
54
50
  }, callback: TwoArgCallback<BigIntStats>): void;
55
- export declare function lstat(path: PathLike, options: StatOptions, callback: TwoArgCallback<Stats | BigIntStats>): void;
51
+ export declare function lstat(path: PathLike, options: Node.StatOptions, callback: TwoArgCallback<Stats | BigIntStats>): void;
56
52
  /**
57
53
  * Asynchronous `truncate`.
58
54
  * @param path
@@ -96,67 +92,47 @@ export declare function open(path: PathLike, flag: string, cb?: TwoArgCallback<n
96
92
  export declare function open(path: PathLike, flag: string, mode: number | string, cb?: TwoArgCallback<number>): void;
97
93
  /**
98
94
  * Asynchronously reads the entire contents of a file.
99
- * @example Usage example
100
- * fs.readFile('/etc/passwd', function (err, data) {
101
- * if (err) throw err;
102
- * console.log(data);
103
- * });
104
95
  * @param filename
105
96
  * @param options
106
- * @option options [String] encoding The string encoding for the file contents. Defaults to `null`.
107
- * @option options [String] flag Defaults to `'r'`.
97
+ * @option options encoding The string encoding for the file contents. Defaults to `null`.
98
+ * @option options flag Defaults to `'r'`.
108
99
  * @param callback If no encoding is specified, then the raw buffer is returned.
109
100
  */
110
101
  export declare function readFile(filename: PathLike, cb: TwoArgCallback<Uint8Array>): void;
111
102
  export declare function readFile(filename: PathLike, options: {
112
103
  flag?: string;
113
104
  }, callback?: TwoArgCallback<Uint8Array>): void;
114
- export declare function readFile(filename: PathLike, options: {
115
- encoding: string;
105
+ export declare function readFile(filename: PathLike, optios: {
106
+ encoding: BufferEncoding;
116
107
  flag?: string;
117
- }, callback?: TwoArgCallback<string>): void;
118
- export declare function readFile(filename: PathLike, encoding: string, cb: TwoArgCallback<string>): void;
108
+ } | BufferEncoding, cb: TwoArgCallback<string>): void;
119
109
  /**
120
110
  * Asynchronously writes data to a file, replacing the file if it already
121
111
  * exists.
122
112
  *
123
113
  * The encoding option is ignored if data is a buffer.
124
114
  *
125
- * @example Usage example
126
- * fs.writeFile('message.txt', 'Hello Node', function (err) {
127
- * if (err) throw err;
128
- * console.log('It\'s saved!');
129
- * });
130
115
  * @param filename
131
116
  * @param data
132
117
  * @param options
133
- * @option options [String] encoding Defaults to `'utf8'`.
134
- * @option options [Number] mode Defaults to `0644`.
135
- * @option options [String] flag Defaults to `'w'`.
118
+ * @option encoding Defaults to `'utf8'`.
119
+ * @option mode Defaults to `0644`.
120
+ * @option flag Defaults to `'w'`.
136
121
  * @param callback
137
122
  */
138
123
  export declare function writeFile(filename: PathLike, data: FileContents, cb?: NoArgCallback): void;
139
- export declare function writeFile(filename: PathLike, data: FileContents, encoding?: string, cb?: NoArgCallback): void;
140
- export declare function writeFile(filename: PathLike, data: FileContents, options?: {
141
- encoding?: string;
142
- mode?: string | number;
143
- flag?: string;
144
- }, cb?: NoArgCallback): void;
124
+ export declare function writeFile(filename: PathLike, data: FileContents, encoding?: BufferEncoding, cb?: NoArgCallback): void;
125
+ export declare function writeFile(filename: PathLike, data: FileContents, options?: Node.WriteFileOptions, cb?: NoArgCallback): void;
145
126
  /**
146
127
  * Asynchronously append data to a file, creating the file if it not yet
147
128
  * exists.
148
129
  *
149
- * @example Usage example
150
- * fs.appendFile('message.txt', 'data to append', function (err) {
151
- * if (err) throw err;
152
- * console.log('The "data to append" was appended to file!');
153
- * });
154
130
  * @param filename
155
131
  * @param data
156
132
  * @param options
157
- * @option options [String] encoding Defaults to `'utf8'`.
158
- * @option options [Number] mode Defaults to `0644`.
159
- * @option options [String] flag Defaults to `'a'`.
133
+ * @option encoding Defaults to `'utf8'`.
134
+ * @option mode Defaults to `0644`.
135
+ * @option flag Defaults to `'a'`.
160
136
  * @param callback
161
137
  */
162
138
  export declare function appendFile(filename: PathLike, data: FileContents, cb?: NoArgCallback): void;
@@ -174,13 +150,12 @@ export declare function appendFile(filename: PathLike, data: FileContents, encod
174
150
  * @param callback
175
151
  */
176
152
  export declare function fstat(fd: number, cb: TwoArgCallback<Stats>): void;
177
- export declare function fstat(fd: number, options: StatOptions & {
153
+ export declare function fstat(fd: number, options: Node.StatOptions & {
178
154
  bigint?: false;
179
155
  }, cb: TwoArgCallback<Stats>): void;
180
- export declare function fstat(fd: number, options: StatOptions & {
156
+ export declare function fstat(fd: number, options: Node.StatOptions & {
181
157
  bigint: true;
182
158
  }, cb: TwoArgCallback<BigIntStats>): void;
183
- export declare function fstat(fd: number, options: StatOptions, cb: TwoArgCallback<Stats | BigIntStats>): void;
184
159
  /**
185
160
  * Asynchronous close.
186
161
  * @param fd
@@ -275,7 +250,7 @@ export declare function rmdir(path: PathLike, cb?: NoArgCallback): void;
275
250
  * @param mode defaults to `0777`
276
251
  * @param callback
277
252
  */
278
- export declare function mkdir(path: PathLike, mode?: any, cb?: NoArgCallback): void;
253
+ export declare function mkdir(path: PathLike, mode?: Node.Mode, cb?: NoArgCallback): void;
279
254
  /**
280
255
  * Asynchronous `readdir`. Reads the contents of a directory.
281
256
  * The callback gets two arguments `(err, files)` where `files` is an array of
@@ -292,29 +267,29 @@ export declare function readdir(path: PathLike, options: {
292
267
  }, cb: TwoArgCallback<Dirent[]>): void;
293
268
  /**
294
269
  * Asynchronous `link`.
295
- * @param srcpath
296
- * @param dstpath
270
+ * @param existing
271
+ * @param newpath
297
272
  * @param callback
298
273
  */
299
- export declare function link(srcpath: PathLike, dstpath: PathLike, cb?: NoArgCallback): void;
274
+ export declare function link(existing: PathLike, newpath: PathLike, cb?: NoArgCallback): void;
300
275
  /**
301
276
  * Asynchronous `symlink`.
302
- * @param srcpath
303
- * @param dstpath
277
+ * @param target target path
278
+ * @param path link path
304
279
  * @param type can be either `'dir'` or `'file'` (default is `'file'`)
305
280
  * @param callback
306
281
  */
307
- export declare function symlink(srcpath: PathLike, dstpath: PathLike, cb?: NoArgCallback): void;
308
- export declare function symlink(srcpath: PathLike, dstpath: PathLike, type?: _symlink.Type, cb?: NoArgCallback): void;
282
+ export declare function symlink(target: PathLike, path: PathLike, cb?: NoArgCallback): void;
283
+ export declare function symlink(target: PathLike, path: PathLike, type?: Node.symlink.Type, cb?: NoArgCallback): void;
309
284
  /**
310
285
  * Asynchronous readlink.
311
286
  * @param path
312
287
  * @param callback
313
288
  */
314
289
  export declare function readlink(path: PathLike, callback: TwoArgCallback<string> & any): void;
315
- export declare function readlink(path: PathLike, options: BufferEncodingOption, callback: TwoArgCallback<Uint8Array>): void;
316
- export declare function readlink(path: PathLike, options: BaseEncodingOptions | string, callback: TwoArgCallback<string | Uint8Array>): void;
317
- export declare function readlink(path: PathLike, options: BaseEncodingOptions | BufferEncoding, callback: TwoArgCallback<string>): void;
290
+ export declare function readlink(path: PathLike, options: Node.BufferEncodingOption, callback: TwoArgCallback<Uint8Array>): void;
291
+ export declare function readlink(path: PathLike, options: Node.BaseEncodingOptions | string, callback: TwoArgCallback<string | Uint8Array>): void;
292
+ export declare function readlink(path: PathLike, options: Node.BaseEncodingOptions | BufferEncoding, callback: TwoArgCallback<string>): void;
318
293
  /**
319
294
  * Asynchronous `chown`.
320
295
  * @param path
@@ -365,17 +340,11 @@ export declare function lutimes(path: PathLike, atime: number | Date, mtime: num
365
340
  * Asynchronous `realpath`. The callback gets two arguments
366
341
  * `(err, resolvedPath)`. May use `process.cwd` to resolve relative paths.
367
342
  *
368
- * @example Usage example
369
- * fs.realpath('/etc/passwd', function (err, resolvedPath) {
370
- * if (err) throw err;
371
- * console.log(resolvedPath);
372
- * });
373
- *
374
343
  * @param path
375
344
  * @param callback
376
345
  */
377
346
  export declare function realpath(path: PathLike, cb?: TwoArgCallback<string>): void;
378
- export declare function realpath(path: PathLike, options: BaseEncodingOptions, cb: TwoArgCallback<string>): void;
347
+ export declare function realpath(path: PathLike, options: Node.BaseEncodingOptions, cb: TwoArgCallback<string>): void;
379
348
  /**
380
349
  * Asynchronous `access`.
381
350
  * @param path
@@ -390,10 +359,10 @@ export declare function watchFile(filename: PathLike, options: {
390
359
  interval?: number;
391
360
  }, listener: (curr: Stats, prev: Stats) => void): void;
392
361
  export declare function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
393
- export declare function watch(filename: PathLike, listener?: (event: string, filename: string) => any): FSWatcher;
362
+ export declare function watch(filename: PathLike, listener?: (event: string, filename: string) => any): Node.FSWatcher;
394
363
  export declare function watch(filename: PathLike, options: {
395
364
  persistent?: boolean;
396
- }, listener?: (event: string, filename: string) => any): FSWatcher;
365
+ }, listener?: (event: string, filename: string) => any): Node.FSWatcher;
397
366
  export declare function createReadStream(path: PathLike, options?: {
398
367
  flags?: string;
399
368
  encoding?: string;
@@ -1,5 +1,6 @@
1
1
  import { ApiError, ErrorCode } from '../ApiError.js';
2
- import { nop, normalizeMode } from './shared.js';
2
+ import { BigIntStats } from '../stats.js';
3
+ import { fd2file, nop, normalizeMode } from './shared.js';
3
4
  import * as promises from './promises.js';
4
5
  import { R_OK } from './constants.js';
5
6
  import { decode, encode } from '../utils.js';
@@ -16,13 +17,10 @@ export function rename(oldPath, newPath, cb = nop) {
16
17
  .then(() => cb())
17
18
  .catch(cb);
18
19
  }
20
+ rename;
19
21
  /**
20
22
  * Test whether or not the given path exists by checking with the file system.
21
23
  * Then call the callback argument with either true or false.
22
- * @example Sample invocation
23
- * fs.exists('/etc/passwd', function (exists) {
24
- * util.debug(exists ? "it's there" : "no passwd!");
25
- * });
26
24
  * @param path
27
25
  * @param callback
28
26
  */
@@ -32,6 +30,7 @@ export function exists(path, cb = nop) {
32
30
  .then(cb)
33
31
  .catch(() => cb(false));
34
32
  }
33
+ exists;
35
34
  export function stat(path, options, callback = nop) {
36
35
  callback = typeof options == 'function' ? options : callback;
37
36
  promises
@@ -39,6 +38,7 @@ export function stat(path, options, callback = nop) {
39
38
  .then(stats => callback(null, stats))
40
39
  .catch(callback);
41
40
  }
41
+ stat;
42
42
  export function lstat(path, options, callback = nop) {
43
43
  callback = typeof options == 'function' ? options : callback;
44
44
  promises
@@ -46,6 +46,7 @@ export function lstat(path, options, callback = nop) {
46
46
  .then(stats => callback(null, stats))
47
47
  .catch(callback);
48
48
  }
49
+ lstat;
49
50
  export function truncate(path, arg2 = 0, cb = nop) {
50
51
  cb = typeof arg2 === 'function' ? arg2 : cb;
51
52
  const len = typeof arg2 === 'number' ? arg2 : 0;
@@ -54,6 +55,7 @@ export function truncate(path, arg2 = 0, cb = nop) {
54
55
  .then(() => cb())
55
56
  .catch(cb);
56
57
  }
58
+ truncate;
57
59
  /**
58
60
  * Asynchronous `unlink`.
59
61
  * @param path
@@ -65,73 +67,96 @@ export function unlink(path, cb = nop) {
65
67
  .then(() => cb())
66
68
  .catch(cb);
67
69
  }
70
+ unlink;
68
71
  export function open(path, flag, arg2, cb = nop) {
69
72
  const mode = normalizeMode(arg2, 0o644);
70
73
  cb = typeof arg2 === 'function' ? arg2 : cb;
71
74
  promises
72
75
  .open(path, flag, mode)
73
- .then(fd => cb(null, fd))
76
+ .then(handle => cb(null, handle.fd))
74
77
  .catch(cb);
75
78
  }
76
- export function readFile(filename, arg2 = {}, cb = nop) {
77
- cb = typeof arg2 === 'function' ? arg2 : cb;
78
- promises.readFile(filename, typeof arg2 === 'function' ? null : arg2);
79
+ open;
80
+ export function readFile(filename, options, cb = nop) {
81
+ cb = typeof options === 'function' ? options : cb;
82
+ promises
83
+ .readFile(filename, typeof options === 'function' ? null : options)
84
+ .then(data => cb(null, data))
85
+ .catch(cb);
79
86
  }
80
- export function writeFile(filename, data, arg3 = {}, cb = nop) {
87
+ readFile;
88
+ export function writeFile(filename, data, arg3, cb = nop) {
81
89
  cb = typeof arg3 === 'function' ? arg3 : cb;
82
- promises.writeFile(filename, data, typeof arg3 === 'function' ? undefined : arg3);
90
+ promises
91
+ .writeFile(filename, data, typeof arg3 != 'function' ? arg3 : null)
92
+ .then(() => cb(null))
93
+ .catch(cb);
83
94
  }
95
+ writeFile;
84
96
  export function appendFile(filename, data, arg3, cb = nop) {
85
97
  cb = typeof arg3 === 'function' ? arg3 : cb;
86
98
  promises.appendFile(filename, data, typeof arg3 === 'function' ? null : arg3);
87
99
  }
100
+ appendFile;
88
101
  export function fstat(fd, options, cb = nop) {
89
102
  cb = typeof options == 'function' ? options : cb;
90
- promises
91
- .fstat(fd, typeof options != 'function' ? options : {})
92
- .then(stats => cb(null, stats))
103
+ fd2file(fd)
104
+ .stat()
105
+ .then(stats => cb(null, (typeof options == 'object' && options?.bigint ? BigIntStats.clone(stats) : stats)))
93
106
  .catch(cb);
94
107
  }
108
+ fstat;
95
109
  /**
96
110
  * Asynchronous close.
97
111
  * @param fd
98
112
  * @param callback
99
113
  */
100
114
  export function close(fd, cb = nop) {
101
- promises
102
- .close(fd)
115
+ new promises.FileHandle(fd)
116
+ .close()
103
117
  .then(() => cb())
104
118
  .catch(cb);
105
119
  }
106
- export function ftruncate(fd, arg2, cb = nop) {
107
- const length = typeof arg2 === 'number' ? arg2 : 0;
108
- cb = typeof arg2 === 'function' ? arg2 : cb;
109
- promises.ftruncate(fd, length);
120
+ close;
121
+ export function ftruncate(fd, lenOrCB, cb = nop) {
122
+ const length = typeof lenOrCB === 'number' ? lenOrCB : 0;
123
+ cb = typeof lenOrCB === 'function' ? lenOrCB : cb;
124
+ const file = fd2file(fd);
125
+ if (length < 0) {
126
+ throw new ApiError(ErrorCode.EINVAL);
127
+ }
128
+ file.truncate(length)
129
+ .then(() => cb())
130
+ .catch(cb);
110
131
  }
132
+ ftruncate;
111
133
  /**
112
134
  * Asynchronous fsync.
113
135
  * @param fd
114
136
  * @param callback
115
137
  */
116
138
  export function fsync(fd, cb = nop) {
117
- promises
118
- .fsync(fd)
139
+ fd2file(fd)
140
+ .sync()
119
141
  .then(() => cb())
120
142
  .catch(cb);
121
143
  }
144
+ fsync;
122
145
  /**
123
146
  * Asynchronous fdatasync.
124
147
  * @param fd
125
148
  * @param callback
126
149
  */
127
150
  export function fdatasync(fd, cb = nop) {
128
- promises
129
- .fdatasync(fd)
151
+ fd2file(fd)
152
+ .datasync()
130
153
  .then(() => cb())
131
154
  .catch(cb);
132
155
  }
156
+ fdatasync;
133
157
  export function write(fd, arg2, arg3, arg4, arg5, cb = nop) {
134
158
  let buffer, offset, length, position = null, encoding;
159
+ const handle = new promises.FileHandle(fd);
135
160
  if (typeof arg2 === 'string') {
136
161
  // Signature 1: (fd, string, [position?, [encoding?]], cb?)
137
162
  encoding = 'utf8';
@@ -156,9 +181,9 @@ export function write(fd, arg2, arg3, arg4, arg5, cb = nop) {
156
181
  offset = 0;
157
182
  length = buffer.length;
158
183
  const _cb = cb;
159
- promises
160
- .write(fd, buffer, offset, length, position)
161
- .then(bytesWritten => _cb(null, bytesWritten, decode(buffer)))
184
+ handle
185
+ .write(buffer, offset, length, position)
186
+ .then(({ bytesWritten }) => _cb(null, bytesWritten, decode(buffer)))
162
187
  .catch(_cb);
163
188
  }
164
189
  else {
@@ -168,12 +193,13 @@ export function write(fd, arg2, arg3, arg4, arg5, cb = nop) {
168
193
  length = arg4;
169
194
  position = typeof arg5 === 'number' ? arg5 : null;
170
195
  const _cb = (typeof arg5 === 'function' ? arg5 : cb);
171
- promises
172
- .write(fd, buffer, offset, length, position)
173
- .then(bytesWritten => _cb(null, bytesWritten, buffer))
196
+ handle
197
+ .write(buffer, offset, length, position)
198
+ .then(({ bytesWritten }) => _cb(null, bytesWritten, buffer))
174
199
  .catch(_cb);
175
200
  }
176
201
  }
202
+ write;
177
203
  /**
178
204
  * Read data from the file specified by `fd`.
179
205
  * @param buffer The buffer that the data will be
@@ -187,11 +213,12 @@ export function write(fd, arg2, arg3, arg4, arg5, cb = nop) {
187
213
  * @param callback The number is the number of bytes read
188
214
  */
189
215
  export function read(fd, buffer, offset, length, position, cb = nop) {
190
- promises
191
- .read(fd, buffer, offset, length, position)
216
+ new promises.FileHandle(fd)
217
+ .read(buffer, offset, length, position)
192
218
  .then(({ bytesRead, buffer }) => cb(null, bytesRead, buffer))
193
219
  .catch(cb);
194
220
  }
221
+ read;
195
222
  /**
196
223
  * Asynchronous `fchown`.
197
224
  * @param fd
@@ -200,11 +227,12 @@ export function read(fd, buffer, offset, length, position, cb = nop) {
200
227
  * @param callback
201
228
  */
202
229
  export function fchown(fd, uid, gid, cb = nop) {
203
- promises
204
- .fchown(fd, uid, gid)
230
+ new promises.FileHandle(fd)
231
+ .chown(uid, gid)
205
232
  .then(() => cb())
206
233
  .catch(cb);
207
234
  }
235
+ fchown;
208
236
  /**
209
237
  * Asynchronous `fchmod`.
210
238
  * @param fd
@@ -212,11 +240,12 @@ export function fchown(fd, uid, gid, cb = nop) {
212
240
  * @param callback
213
241
  */
214
242
  export function fchmod(fd, mode, cb) {
215
- promises
216
- .fchmod(fd, mode)
243
+ new promises.FileHandle(fd)
244
+ .chmod(mode)
217
245
  .then(() => cb())
218
246
  .catch(cb);
219
247
  }
248
+ fchmod;
220
249
  /**
221
250
  * Change the file timestamps of a file referenced by the supplied file
222
251
  * descriptor.
@@ -226,11 +255,12 @@ export function fchmod(fd, mode, cb) {
226
255
  * @param callback
227
256
  */
228
257
  export function futimes(fd, atime, mtime, cb = nop) {
229
- promises
230
- .futimes(fd, atime, mtime)
258
+ new promises.FileHandle(fd)
259
+ .utimes(atime, mtime)
231
260
  .then(() => cb())
232
261
  .catch(cb);
233
262
  }
263
+ futimes;
234
264
  /**
235
265
  * Asynchronous `rmdir`.
236
266
  * @param path
@@ -242,6 +272,7 @@ export function rmdir(path, cb = nop) {
242
272
  .then(() => cb())
243
273
  .catch(cb);
244
274
  }
275
+ rmdir;
245
276
  /**
246
277
  * Asynchronous `mkdir`.
247
278
  * @param path
@@ -254,6 +285,7 @@ export function mkdir(path, mode, cb = nop) {
254
285
  .then(() => cb())
255
286
  .catch(cb);
256
287
  }
288
+ mkdir;
257
289
  export function readdir(path, _options, cb = nop) {
258
290
  cb = typeof _options == 'function' ? _options : cb;
259
291
  const options = typeof _options != 'function' ? _options : {};
@@ -263,26 +295,29 @@ export function readdir(path, _options, cb = nop) {
263
295
  .then(entries => cb(null, entries))
264
296
  .catch(cb);
265
297
  }
298
+ readdir;
266
299
  /**
267
300
  * Asynchronous `link`.
268
- * @param srcpath
269
- * @param dstpath
301
+ * @param existing
302
+ * @param newpath
270
303
  * @param callback
271
304
  */
272
- export function link(srcpath, dstpath, cb = nop) {
305
+ export function link(existing, newpath, cb = nop) {
273
306
  promises
274
- .link(srcpath, dstpath)
307
+ .link(existing, newpath)
275
308
  .then(() => cb())
276
309
  .catch(cb);
277
310
  }
278
- export function symlink(srcpath, dstpath, arg3, cb = nop) {
279
- const type = typeof arg3 === 'string' ? arg3 : 'file';
280
- cb = typeof arg3 === 'function' ? arg3 : cb;
311
+ link;
312
+ export function symlink(target, path, typeOrCB, cb = nop) {
313
+ const type = typeof typeOrCB === 'string' ? typeOrCB : 'file';
314
+ cb = typeof typeOrCB === 'function' ? typeOrCB : cb;
281
315
  promises
282
- .symlink(srcpath, dstpath, typeof arg3 === 'function' ? null : arg3)
316
+ .symlink(target, path, type)
283
317
  .then(() => cb())
284
318
  .catch(cb);
285
319
  }
320
+ symlink;
286
321
  export function readlink(path, options, callback = nop) {
287
322
  callback = typeof options == 'function' ? options : callback;
288
323
  promises
@@ -290,6 +325,7 @@ export function readlink(path, options, callback = nop) {
290
325
  .then(result => callback(null, result))
291
326
  .catch(callback);
292
327
  }
328
+ readlink;
293
329
  /**
294
330
  * Asynchronous `chown`.
295
331
  * @param path
@@ -303,6 +339,7 @@ export function chown(path, uid, gid, cb = nop) {
303
339
  .then(() => cb())
304
340
  .catch(cb);
305
341
  }
342
+ chown;
306
343
  /**
307
344
  * Asynchronous `lchown`.
308
345
  * @param path
@@ -316,6 +353,7 @@ export function lchown(path, uid, gid, cb = nop) {
316
353
  .then(() => cb())
317
354
  .catch(cb);
318
355
  }
356
+ lchown;
319
357
  /**
320
358
  * Asynchronous `chmod`.
321
359
  * @param path
@@ -328,6 +366,7 @@ export function chmod(path, mode, cb = nop) {
328
366
  .then(() => cb())
329
367
  .catch(cb);
330
368
  }
369
+ chmod;
331
370
  /**
332
371
  * Asynchronous `lchmod`.
333
372
  * @param path
@@ -340,6 +379,7 @@ export function lchmod(path, mode, cb = nop) {
340
379
  .then(() => cb())
341
380
  .catch(cb);
342
381
  }
382
+ lchmod;
343
383
  /**
344
384
  * Change file timestamps of the file referenced by the supplied path.
345
385
  * @param path
@@ -353,6 +393,7 @@ export function utimes(path, atime, mtime, cb = nop) {
353
393
  .then(() => cb())
354
394
  .catch(cb);
355
395
  }
396
+ utimes;
356
397
  /**
357
398
  * Change file timestamps of the file referenced by the supplied path.
358
399
  * @param path
@@ -366,6 +407,7 @@ export function lutimes(path, atime, mtime, cb = nop) {
366
407
  .then(() => cb())
367
408
  .catch(cb);
368
409
  }
410
+ lutimes;
369
411
  export function realpath(path, arg2, cb = nop) {
370
412
  cb = typeof arg2 === 'function' ? arg2 : cb;
371
413
  promises
@@ -373,6 +415,7 @@ export function realpath(path, arg2, cb = nop) {
373
415
  .then(result => cb(null, result))
374
416
  .catch(cb);
375
417
  }
418
+ realpath;
376
419
  export function access(path, arg2, cb = nop) {
377
420
  const mode = typeof arg2 === 'number' ? arg2 : R_OK;
378
421
  cb = typeof arg2 === 'function' ? arg2 : cb;
@@ -381,6 +424,7 @@ export function access(path, arg2, cb = nop) {
381
424
  .then(() => cb())
382
425
  .catch(cb);
383
426
  }
427
+ access;
384
428
  export function watchFile(filename, arg2, listener = nop) {
385
429
  throw new ApiError(ErrorCode.ENOTSUP);
386
430
  }
@@ -68,7 +68,7 @@ export const O_DIRECT = 0o40000;
68
68
  export const O_NONBLOCK = 0o4000;
69
69
  // File Type Constants
70
70
  /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */
71
- export const S_IFMT = 0o170000;
71
+ export const S_IFMT = 0xf000;
72
72
  /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */
73
73
  export const S_IFREG = 0o100000;
74
74
  /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */