@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,12 +1,151 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="node" resolution-mode="require"/>
3
- import type { ReadStream, WriteStream, FSWatcher, symlink as _symlink, BaseEncodingOptions, BufferEncodingOption, BigIntOptions } from 'node:fs';
4
- import * as constants from './constants.js';
5
- export { constants };
6
- import { PathLike } from './shared.js';
3
+ /// <reference types="node" resolution-mode="require"/>
4
+ import type * as Node from 'node:fs';
5
+ export * as constants from './constants.js';
6
+ import type { PathLike, BufferToUint8Array } from './shared.js';
7
7
  import { FileContents } from '../filesystem.js';
8
8
  import { BigIntStats, Stats } from '../stats.js';
9
9
  import { Dirent } from './dir.js';
10
+ export declare class FileHandle implements BufferToUint8Array<Node.promises.FileHandle> {
11
+ /**
12
+ * Gets the file descriptor for this file handle.
13
+ */
14
+ readonly fd: number;
15
+ constructor(
16
+ /**
17
+ * Gets the file descriptor for this file handle.
18
+ */
19
+ fd: number);
20
+ /**
21
+ * Asynchronous fchown(2) - Change ownership of a file.
22
+ */
23
+ chown(uid: number, gid: number): Promise<void>;
24
+ /**
25
+ * Asynchronous fchmod(2) - Change permissions of a file.
26
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
27
+ */
28
+ chmod(mode: Node.Mode): Promise<void>;
29
+ /**
30
+ * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
31
+ */
32
+ datasync(): Promise<void>;
33
+ /**
34
+ * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
35
+ */
36
+ sync(): Promise<void>;
37
+ /**
38
+ * Asynchronous ftruncate(2) - Truncate a file to a specified length.
39
+ * @param len If not specified, defaults to `0`.
40
+ */
41
+ truncate(len?: number): Promise<void>;
42
+ /**
43
+ * Asynchronously change file timestamps of the file.
44
+ * @param atime The last access time. If a string is provided, it will be coerced to number.
45
+ * @param mtime The last modified time. If a string is provided, it will be coerced to number.
46
+ */
47
+ utimes(atime: string | number | Date, mtime: string | number | Date): Promise<void>;
48
+ /**
49
+ * Asynchronously append data to a file, creating the file if it does not exist. The underlying file will _not_ be closed automatically.
50
+ * The `FileHandle` must have been opened for appending.
51
+ * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
52
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
53
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
54
+ * If `mode` is not supplied, the default of `0o666` is used.
55
+ * If `mode` is a string, it is parsed as an octal integer.
56
+ * If `flag` is not supplied, the default of `'a'` is used.
57
+ */
58
+ appendFile(data: string | Uint8Array, options?: {
59
+ encoding?: BufferEncoding;
60
+ mode?: Node.Mode;
61
+ flag?: Node.OpenMode;
62
+ } | BufferEncoding): Promise<void>;
63
+ /**
64
+ * Asynchronously reads data from the file.
65
+ * The `FileHandle` must have been opened for reading.
66
+ * @param buffer The buffer that the data will be written to.
67
+ * @param offset The offset in the buffer at which to start writing.
68
+ * @param length The number of bytes to read.
69
+ * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
70
+ */
71
+ read<TBuffer extends Uint8Array>(buffer: TBuffer, offset?: number, length?: number, position?: number): Promise<{
72
+ bytesRead: number;
73
+ buffer: TBuffer;
74
+ }>;
75
+ /**
76
+ * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
77
+ * The `FileHandle` must have been opened for reading.
78
+ * @param options An object that may contain an optional flag.
79
+ * If a flag is not provided, it defaults to `'r'`.
80
+ */
81
+ readFile(options?: {
82
+ flag?: Node.OpenMode;
83
+ }): Promise<Uint8Array>;
84
+ readFile(options: {
85
+ encoding: BufferEncoding;
86
+ flag?: Node.OpenMode;
87
+ } | BufferEncoding): Promise<string>;
88
+ /**
89
+ * Asynchronous fstat(2) - Get file status.
90
+ */
91
+ stat(opts: Node.BigIntOptions): Promise<BigIntStats>;
92
+ stat(opts?: Node.StatOptions & {
93
+ bigint?: false;
94
+ }): Promise<Stats>;
95
+ write(data: FileContents, posOrOff?: number, lenOrEnc?: BufferEncoding | number, position?: number): Promise<{
96
+ bytesWritten: number;
97
+ buffer: FileContents;
98
+ }>;
99
+ /**
100
+ * Asynchronously writes `buffer` to the file.
101
+ * The `FileHandle` must have been opened for writing.
102
+ * @param buffer The buffer that the data will be written to.
103
+ * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
104
+ * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
105
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
106
+ */
107
+ write(buffer: Uint8Array, offset?: number, length?: number, position?: number): Promise<{
108
+ bytesWritten: number;
109
+ buffer: Uint8Array;
110
+ }>;
111
+ /**
112
+ * Asynchronously writes `string` to the file.
113
+ * The `FileHandle` must have been opened for writing.
114
+ * It is unsafe to call `write()` multiple times on the same file without waiting for the `Promise`
115
+ * to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
116
+ * @param string A string to write.
117
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
118
+ * @param encoding The expected string encoding.
119
+ */
120
+ write(data: string, position?: number, encoding?: BufferEncoding): Promise<{
121
+ bytesWritten: number;
122
+ buffer: string;
123
+ }>;
124
+ /**
125
+ * Asynchronously writes data to a file, replacing the file if it already exists. The underlying file will _not_ be closed automatically.
126
+ * The `FileHandle` must have been opened for writing.
127
+ * It is unsafe to call `writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected).
128
+ * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
129
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
130
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
131
+ * If `mode` is not supplied, the default of `0o666` is used.
132
+ * If `mode` is a string, it is parsed as an octal integer.
133
+ * If `flag` is not supplied, the default of `'w'` is used.
134
+ */
135
+ writeFile(data: string | Uint8Array, options?: Node.WriteFileOptions): Promise<void>;
136
+ /**
137
+ * See `fs.writev` promisified version.
138
+ */
139
+ writev(buffers: ReadonlyArray<Uint8Array>, position?: number): Promise<Node.WriteVResult>;
140
+ /**
141
+ * See `fs.readv` promisified version.
142
+ */
143
+ readv(buffers: ReadonlyArray<Uint8Array>, position?: number): Promise<Node.ReadVResult>;
144
+ /**
145
+ * Asynchronous close(2) - close a `FileHandle`.
146
+ */
147
+ close(): Promise<void>;
148
+ }
10
149
  /**
11
150
  * Renames a file
12
151
  * @param oldPath
@@ -15,24 +154,25 @@ import { Dirent } from './dir.js';
15
154
  export declare function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
16
155
  /**
17
156
  * Test whether or not the given path exists by checking with the file system.
18
- * @param path
157
+ * @param _path
19
158
  */
20
- export declare function exists(path: PathLike): Promise<boolean>;
159
+ export declare function exists(_path: PathLike): Promise<boolean>;
21
160
  /**
22
161
  * `stat`.
23
162
  * @param path
24
163
  * @returns Stats
25
164
  */
26
- export declare function stat(path: PathLike, options: BigIntOptions): Promise<BigIntStats>;
165
+ export declare function stat(path: PathLike, options: Node.BigIntOptions): Promise<BigIntStats>;
27
166
  export declare function stat(path: PathLike, options?: {
28
167
  bigint?: false;
29
168
  }): Promise<Stats>;
169
+ export declare function stat(path: PathLike, options?: Node.StatOptions): Promise<Stats | BigIntStats>;
30
170
  /**
31
171
  * `lstat`.
32
172
  * `lstat()` is identical to `stat()`, except that if path is a symbolic link,
33
173
  * then the link itself is stat-ed, not the file that it refers to.
34
174
  * @param path
35
- * @return [ZenFS.node.fs.Stats]
175
+ * @return
36
176
  */
37
177
  export declare function lstat(path: PathLike, options?: {
38
178
  bigint?: false;
@@ -52,126 +192,78 @@ export declare function truncate(path: PathLike, len?: number): Promise<void>;
52
192
  */
53
193
  export declare function unlink(path: PathLike): Promise<void>;
54
194
  /**
55
- * file open.
195
+ * Asynchronous file open.
56
196
  * @see http://www.manpagez.com/man/2/open/
57
- * @param path
58
- * @param flags
59
- * @param mode defaults to `0644`
197
+ * @param flags Handles the complexity of the various file modes. See its API for more details.
198
+ * @param mode Mode to use to open the file. Can be ignored if the filesystem doesn't support permissions.
199
+ */
200
+ export declare function open(path: PathLike, flag: string, mode?: Node.Mode): Promise<FileHandle>;
201
+ /**
202
+ * Opens a file without resolving symlinks
203
+ * @internal
60
204
  */
61
- export declare function open(path: PathLike, flag: string, mode?: number | string): Promise<number>;
205
+ export declare function lopen(path: PathLike, flag: string, mode?: Node.Mode): Promise<FileHandle>;
62
206
  /**
63
- * Synchronously reads the entire contents of a file.
207
+ * Asynchronously reads the entire contents of a file.
64
208
  * @param filename
65
209
  * @param options
66
210
  * options.encoding The string encoding for the file contents. Defaults to `null`.
67
211
  * options.flag Defaults to `'r'`.
68
- * @return Uint8Array
212
+ * @returns file data
69
213
  */
70
214
  export declare function readFile(filename: PathLike, options?: {
71
- flag?: string;
215
+ flag?: Node.OpenMode;
72
216
  }): Promise<Uint8Array>;
73
217
  export declare function readFile(filename: PathLike, options: {
74
- encoding: string;
75
- flag?: string;
76
- }): Promise<string>;
77
- export declare function readFile(filename: PathLike, encoding: string): Promise<string>;
218
+ encoding?: BufferEncoding;
219
+ flag?: Node.OpenMode;
220
+ } | BufferEncoding): Promise<string>;
78
221
  /**
79
- * Synchronously writes data to a file, replacing the file if it already
80
- * exists.
222
+ * Synchronously writes data to a file, replacing the file if it already exists.
81
223
  *
82
224
  * The encoding option is ignored if data is a buffer.
83
225
  * @param filename
84
226
  * @param data
85
- * @param options
86
- * @option options [String] encoding Defaults to `'utf8'`.
87
- * @option options [Number] mode Defaults to `0644`.
88
- * @option options [String] flag Defaults to `'w'`.
227
+ * @param _options
228
+ * @option options encoding Defaults to `'utf8'`.
229
+ * @option options mode Defaults to `0644`.
230
+ * @option options flag Defaults to `'w'`.
89
231
  */
90
- export declare function writeFile(filename: PathLike, data: FileContents, options?: {
91
- encoding?: string;
92
- mode?: number | string;
93
- flag?: string;
94
- }): Promise<void>;
95
- export declare function writeFile(filename: PathLike, data: FileContents, encoding?: string): Promise<void>;
96
- export declare function writeFile(filename: PathLike, data: FileContents, options?: {
97
- encoding?: string;
98
- mode?: number | string;
99
- flag?: string;
100
- } | string): Promise<void>;
232
+ export declare function writeFile(filename: PathLike, data: FileContents, _options?: Node.WriteFileOptions): Promise<void>;
101
233
  /**
102
234
  * Asynchronously append data to a file, creating the file if it not yet
103
235
  * exists.
104
- *
105
- * @example Usage example
106
- * fs.appendFile('message.txt', 'data to append', function (err) {
107
- * if (err) throw err;
108
- * console.log('The "data to append" was appended to file!');
109
- * });
110
236
  * @param filename
111
237
  * @param data
112
238
  * @param options
113
- * @option options [String] encoding Defaults to `'utf8'`.
114
- * @option options [Number] mode Defaults to `0644`.
115
- * @option options [String] flag Defaults to `'a'`.
116
- */
117
- export declare function appendFile(filename: PathLike, data: FileContents, options?: {
118
- encoding?: string;
119
- mode?: number | string;
120
- flag?: string;
121
- }): Promise<void>;
122
- export declare function appendFile(filename: PathLike, data: FileContents, encoding?: string): Promise<void>;
123
- /**
124
- * `fstat`.
125
- * `fstat()` is identical to `stat()`, except that the file to be stat-ed is
126
- * specified by the file descriptor `fd`.
127
- * @param fd
128
- * @return [ZenFS.node.fs.Stats]
129
- */
130
- export declare function fstat(fd: number, options?: {
131
- bigint?: false;
132
- }): Promise<Stats>;
133
- export declare function fstat(fd: number, options: {
134
- bigint: true;
135
- }): Promise<BigIntStats>;
136
- /**
137
- * close.
138
- * @param fd
239
+ * @option options encoding Defaults to `'utf8'`.
240
+ * @option options mode Defaults to `0644`.
241
+ * @option options flag Defaults to `'a'`.
139
242
  */
140
- export declare function close(fd: number): Promise<void>;
141
- /**
142
- * ftruncate.
143
- * @param fd
144
- * @param len
145
- */
146
- export declare function ftruncate(fd: number, len?: number): Promise<void>;
147
- /**
148
- * fsync.
149
- * @param fd
150
- */
151
- export declare function fsync(fd: number): Promise<void>;
152
- /**
153
- * fdatasync.
154
- * @param fd
155
- */
156
- export declare function fdatasync(fd: number): Promise<void>;
243
+ export declare function appendFile(filename: PathLike, data: FileContents, _options?: BufferEncoding | (Node.BaseEncodingOptions & {
244
+ mode?: Node.Mode;
245
+ flag?: Node.OpenMode;
246
+ })): Promise<void>;
157
247
  /**
158
248
  * Write buffer to the file specified by `fd`.
159
- * Note that it is unsafe to use fs.write multiple times on the same file
160
- * without waiting for it to return.
161
- * @param fd
162
- * @param buffer Uint8Array containing the data to write to
163
- * the file.
249
+ * Note that it is unsafe to use fs.write multiple times on the same file without waiting for it to return.
250
+ * @param handle
251
+ * @param data Uint8Array containing the data to write to the file.
164
252
  * @param offset Offset in the buffer to start reading data from.
165
253
  * @param length The amount of bytes to write to the file.
166
- * @param position Offset from the beginning of the file where this
167
- * data should be written. If position is null, the data will be written at
168
- * the current position.
254
+ * @param position Offset from the beginning of the file where this data should be written. If position is null, the data will be written at the current position.
169
255
  */
170
- export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number): Promise<number>;
171
- export declare function write(fd: number, data: string, position?: number | null, encoding?: BufferEncoding): Promise<number>;
256
+ export declare function write(handle: FileHandle, data: Uint8Array, offset: number, length: number, position?: number): Promise<{
257
+ bytesWritten: number;
258
+ buffer: Uint8Array;
259
+ }>;
260
+ export declare function write(handle: FileHandle, data: string, position?: number, encoding?: BufferEncoding): Promise<{
261
+ bytesWritten: number;
262
+ buffer: string;
263
+ }>;
172
264
  /**
173
265
  * Read data from the file specified by `fd`.
174
- * @param fd
266
+ * @param handle
175
267
  * @param buffer The buffer that the data will be
176
268
  * written to.
177
269
  * @param offset The offset within the buffer where writing will
@@ -181,31 +273,31 @@ export declare function write(fd: number, data: string, position?: number | null
181
273
  * in the file. If position is null, data will be read from the current file
182
274
  * position.
183
275
  */
184
- export declare function read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number): Promise<{
276
+ export declare function read(handle: FileHandle, buffer: Uint8Array, offset: number, length: number, position?: number): Promise<{
185
277
  bytesRead: number;
186
278
  buffer: Uint8Array;
187
279
  }>;
188
280
  /**
189
281
  * `fchown`.
190
- * @param fd
282
+ * @param handle
191
283
  * @param uid
192
284
  * @param gid
193
285
  */
194
- export declare function fchown(fd: number, uid: number, gid: number): Promise<void>;
286
+ export declare function fchown(handle: FileHandle, uid: number, gid: number): Promise<void>;
195
287
  /**
196
288
  * `fchmod`.
197
- * @param fd
289
+ * @param handle
198
290
  * @param mode
199
291
  */
200
- export declare function fchmod(fd: number, mode: number | string): Promise<void>;
292
+ export declare function fchmod(handle: FileHandle, mode: Node.Mode): Promise<void>;
201
293
  /**
202
294
  * Change the file timestamps of a file referenced by the supplied file
203
295
  * descriptor.
204
- * @param fd
296
+ * @param handle
205
297
  * @param atime
206
298
  * @param mtime
207
299
  */
208
- export declare function futimes(fd: number, atime: number | Date, mtime: number | Date): Promise<void>;
300
+ export declare function futimes(handle: FileHandle, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
209
301
  /**
210
302
  * `rmdir`.
211
303
  * @param path
@@ -216,37 +308,44 @@ export declare function rmdir(path: PathLike): Promise<void>;
216
308
  * @param path
217
309
  * @param mode defaults to `0777`
218
310
  */
219
- export declare function mkdir(path: PathLike, mode?: number | string): Promise<void>;
311
+ export declare function mkdir(path: PathLike, mode?: Node.Mode | (Node.MakeDirectoryOptions & {
312
+ recursive?: false;
313
+ })): Promise<void>;
314
+ export declare function mkdir(path: PathLike, mode: Node.MakeDirectoryOptions & {
315
+ recursive: true;
316
+ }): Promise<string>;
220
317
  /**
221
318
  * `readdir`. Reads the contents of a directory.
222
319
  * @param path
223
320
  */
224
- export declare function readdir(path: PathLike, options: {
321
+ export declare function readdir(path: PathLike, options?: (Node.BaseEncodingOptions & {
322
+ withFileTypes?: false;
323
+ }) | BufferEncoding): Promise<string[]>;
324
+ export declare function readdir(path: PathLike, options: Node.BufferEncodingOption & {
225
325
  withFileTypes?: false;
226
- }): Promise<string[]>;
227
- export declare function readdir(path: PathLike, options: {
326
+ }): Promise<Uint8Array[]>;
327
+ export declare function readdir(path: PathLike, options: Node.BaseEncodingOptions & {
228
328
  withFileTypes: true;
229
329
  }): Promise<Dirent[]>;
230
330
  /**
231
331
  * `link`.
232
- * @param srcpath
233
- * @param dstpath
332
+ * @param existing
333
+ * @param newpath
234
334
  */
235
- export declare function link(srcpath: PathLike, dstpath: PathLike): Promise<void>;
335
+ export declare function link(existing: PathLike, newpath: PathLike): Promise<void>;
236
336
  /**
237
337
  * `symlink`.
238
- * @param srcpath
239
- * @param dstpath
338
+ * @param target target path
339
+ * @param path link path
240
340
  * @param type can be either `'dir'` or `'file'` (default is `'file'`)
241
341
  */
242
- export declare function symlink(srcpath: PathLike, dstpath: PathLike, type?: _symlink.Type): Promise<void>;
342
+ export declare function symlink(target: PathLike, path: PathLike, type?: Node.symlink.Type): Promise<void>;
243
343
  /**
244
344
  * readlink.
245
345
  * @param path
246
346
  */
247
- export declare function readlink(path: PathLike, options?: BaseEncodingOptions | BufferEncoding): Promise<string>;
248
- export declare function readlink(path: PathLike, options: BufferEncodingOption): Promise<Uint8Array>;
249
- export declare function readlink(path: PathLike, options?: BaseEncodingOptions | string): Promise<string | Uint8Array>;
347
+ export declare function readlink(path: PathLike, options: Node.BufferEncodingOption): Promise<Uint8Array>;
348
+ export declare function readlink(path: PathLike, options?: Node.BaseEncodingOptions | BufferEncoding): Promise<string>;
250
349
  /**
251
350
  * `chown`.
252
351
  * @param path
@@ -266,20 +365,20 @@ export declare function lchown(path: PathLike, uid: number, gid: number): Promis
266
365
  * @param path
267
366
  * @param mode
268
367
  */
269
- export declare function chmod(path: PathLike, mode: string | number): Promise<void>;
368
+ export declare function chmod(path: PathLike, mode: Node.Mode): Promise<void>;
270
369
  /**
271
370
  * `lchmod`.
272
371
  * @param path
273
372
  * @param mode
274
373
  */
275
- export declare function lchmod(path: PathLike, mode: number | string): Promise<void>;
374
+ export declare function lchmod(path: PathLike, mode: Node.Mode): Promise<void>;
276
375
  /**
277
376
  * Change file timestamps of the file referenced by the supplied path.
278
377
  * @param path
279
378
  * @param atime
280
379
  * @param mtime
281
380
  */
282
- export declare function utimes(path: PathLike, atime: number | Date, mtime: number | Date): Promise<void>;
381
+ export declare function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
283
382
  /**
284
383
  * Change file timestamps of the file referenced by the supplied path.
285
384
  * @param path
@@ -288,24 +387,24 @@ export declare function utimes(path: PathLike, atime: number | Date, mtime: numb
288
387
  */
289
388
  export declare function lutimes(path: PathLike, atime: number | Date, mtime: number | Date): Promise<void>;
290
389
  /**
291
- * `realpath`.
292
- * @param path
293
- * @param options
294
- * @return resolved path
390
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
391
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
392
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
295
393
  *
296
394
  * Note: This *Can not* use doOp since doOp depends on it
297
395
  */
298
- export declare function realpath(path: PathLike, options?: BaseEncodingOptions): Promise<string>;
396
+ export declare function realpath(path: PathLike, options: Node.BufferEncodingOption): Promise<Uint8Array>;
397
+ export declare function realpath(path: PathLike, options?: Node.BaseEncodingOptions | BufferEncoding): Promise<string>;
299
398
  export declare function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): Promise<void>;
300
399
  export declare function watchFile(filename: PathLike, options: {
301
400
  persistent?: boolean;
302
401
  interval?: number;
303
402
  }, listener: (curr: Stats, prev: Stats) => void): Promise<void>;
304
403
  export declare function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): Promise<void>;
305
- export declare function watch(filename: PathLike, listener?: (event: string, filename: PathLike) => any): Promise<FSWatcher>;
404
+ export declare function watch(filename: PathLike, listener?: (event: string, filename: PathLike) => any): Promise<Node.FSWatcher>;
306
405
  export declare function watch(filename: PathLike, options: {
307
406
  persistent?: boolean;
308
- }, listener?: (event: string, filename: string) => any): Promise<FSWatcher>;
407
+ }, listener?: (event: string, filename: string) => any): Promise<Node.FSWatcher>;
309
408
  /**
310
409
  * `access`.
311
410
  * @param path
@@ -318,13 +417,13 @@ export declare function createReadStream(path: PathLike, options?: {
318
417
  fd?: number;
319
418
  mode?: number;
320
419
  autoClose?: boolean;
321
- }): Promise<ReadStream>;
420
+ }): Promise<Node.ReadStream>;
322
421
  export declare function createWriteStream(path: PathLike, options?: {
323
422
  flags?: string;
324
423
  encoding?: string;
325
424
  fd?: number;
326
425
  mode?: number;
327
- }): Promise<WriteStream>;
426
+ }): Promise<Node.WriteStream>;
328
427
  export declare function rm(path: PathLike): Promise<void>;
329
428
  export declare function mkdtemp(path: PathLike): Promise<void>;
330
429
  export declare function copyFile(path: PathLike): Promise<void>;