@zenfs/core 0.0.12 → 0.1.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.
- package/dist/ApiError.d.ts +1 -1
- package/dist/ApiError.js +17 -16
- package/dist/backends/AsyncMirror.js +40 -46
- package/dist/backends/AsyncStore.js +326 -383
- package/dist/backends/FolderAdapter.js +8 -19
- package/dist/backends/Locked.js +91 -137
- package/dist/backends/OverlayFS.js +234 -279
- package/dist/backends/SyncStore.js +2 -2
- package/dist/backends/backend.d.ts +6 -6
- package/dist/browser.min.js +23 -6
- package/dist/browser.min.js.map +4 -4
- package/dist/emulation/callbacks.d.ts +109 -72
- package/dist/emulation/callbacks.js +40 -47
- package/dist/emulation/dir.d.ts +55 -0
- package/dist/emulation/dir.js +104 -0
- package/dist/emulation/fs.d.ts +1 -2
- package/dist/emulation/fs.js +0 -1
- package/dist/emulation/index.d.ts +3 -0
- package/dist/emulation/index.js +3 -0
- package/dist/emulation/promises.d.ts +71 -50
- package/dist/emulation/promises.js +243 -342
- package/dist/emulation/shared.d.ts +14 -0
- package/dist/emulation/shared.js +4 -3
- package/dist/emulation/streams.d.ts +102 -0
- package/dist/emulation/streams.js +55 -0
- package/dist/emulation/sync.d.ts +81 -52
- package/dist/emulation/sync.js +98 -65
- package/dist/file.d.ts +11 -5
- package/dist/file.js +79 -76
- package/dist/filesystem.d.ts +3 -3
- package/dist/filesystem.js +181 -262
- package/dist/index.d.ts +3 -3
- package/dist/index.js +39 -53
- package/dist/stats.d.ts +80 -27
- package/dist/stats.js +142 -93
- package/dist/utils.d.ts +2 -6
- package/dist/utils.js +79 -78
- package/package.json +4 -2
- package/readme.md +2 -40
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import { Stats } from '../stats.js';
|
|
3
|
+
import type { BaseEncodingOptions, BufferEncodingOption, FSWatcher, StatOptions, symlink as _symlink } from 'fs';
|
|
4
|
+
import { TwoArgCallback, NoArgCallback, ThreeArgCallback, FileContents } from '../filesystem.js';
|
|
5
|
+
import { BigIntStats, Stats } from '../stats.js';
|
|
6
|
+
import { PathLike } from './shared.js';
|
|
7
|
+
import { ReadStream, WriteStream } from './streams.js';
|
|
8
|
+
import { Dirent } from './dir.js';
|
|
6
9
|
/**
|
|
7
10
|
* Asynchronous rename. No arguments other than a possible exception are given
|
|
8
11
|
* to the completion callback.
|
|
@@ -10,7 +13,7 @@ import { Stats } from '../stats.js';
|
|
|
10
13
|
* @param newPath
|
|
11
14
|
* @param callback
|
|
12
15
|
*/
|
|
13
|
-
export declare function rename(oldPath:
|
|
16
|
+
export declare function rename(oldPath: PathLike, newPath: PathLike, cb?: NoArgCallback): void;
|
|
14
17
|
/**
|
|
15
18
|
* Test whether or not the given path exists by checking with the file system.
|
|
16
19
|
* Then call the callback argument with either true or false.
|
|
@@ -21,13 +24,20 @@ export declare function rename(oldPath: string, newPath: string, cb?: BFSOneArgC
|
|
|
21
24
|
* @param path
|
|
22
25
|
* @param callback
|
|
23
26
|
*/
|
|
24
|
-
export declare function exists(path:
|
|
27
|
+
export declare function exists(path: PathLike, cb?: (exists: boolean) => unknown): void;
|
|
25
28
|
/**
|
|
26
29
|
* Asynchronous `stat`.
|
|
27
30
|
* @param path
|
|
28
31
|
* @param callback
|
|
29
32
|
*/
|
|
30
|
-
export declare function stat(path:
|
|
33
|
+
export declare function stat(path: PathLike, callback: TwoArgCallback<Stats>): void;
|
|
34
|
+
export declare function stat(path: PathLike, options: StatOptions & {
|
|
35
|
+
bigint?: false;
|
|
36
|
+
}, callback: TwoArgCallback<Stats>): void;
|
|
37
|
+
export declare function stat(path: PathLike, options: StatOptions & {
|
|
38
|
+
bigint: true;
|
|
39
|
+
}, callback: TwoArgCallback<BigIntStats>): void;
|
|
40
|
+
export declare function stat(path: PathLike, options: StatOptions, callback: TwoArgCallback<Stats | BigIntStats>): void;
|
|
31
41
|
/**
|
|
32
42
|
* Asynchronous `lstat`.
|
|
33
43
|
* `lstat()` is identical to `stat()`, except that if path is a symbolic link,
|
|
@@ -35,21 +45,28 @@ export declare function stat(path: string, cb?: BFSCallback<Stats>): void;
|
|
|
35
45
|
* @param path
|
|
36
46
|
* @param callback
|
|
37
47
|
*/
|
|
38
|
-
export declare function lstat(path:
|
|
48
|
+
export declare function lstat(path: PathLike, callback: TwoArgCallback<Stats>): void;
|
|
49
|
+
export declare function lstat(path: PathLike, options: StatOptions & {
|
|
50
|
+
bigint?: false;
|
|
51
|
+
}, callback: TwoArgCallback<Stats>): void;
|
|
52
|
+
export declare function lstat(path: PathLike, options: StatOptions & {
|
|
53
|
+
bigint: true;
|
|
54
|
+
}, callback: TwoArgCallback<BigIntStats>): void;
|
|
55
|
+
export declare function lstat(path: PathLike, options: StatOptions, callback: TwoArgCallback<Stats | BigIntStats>): void;
|
|
39
56
|
/**
|
|
40
57
|
* Asynchronous `truncate`.
|
|
41
58
|
* @param path
|
|
42
59
|
* @param len
|
|
43
60
|
* @param callback
|
|
44
61
|
*/
|
|
45
|
-
export declare function truncate(path:
|
|
46
|
-
export declare function truncate(path:
|
|
62
|
+
export declare function truncate(path: PathLike, cb?: NoArgCallback): void;
|
|
63
|
+
export declare function truncate(path: PathLike, len: number, cb?: NoArgCallback): void;
|
|
47
64
|
/**
|
|
48
65
|
* Asynchronous `unlink`.
|
|
49
66
|
* @param path
|
|
50
67
|
* @param callback
|
|
51
68
|
*/
|
|
52
|
-
export declare function unlink(path:
|
|
69
|
+
export declare function unlink(path: PathLike, cb?: NoArgCallback): void;
|
|
53
70
|
/**
|
|
54
71
|
* Asynchronous file open.
|
|
55
72
|
* Exclusive mode ensures that path is newly created.
|
|
@@ -75,8 +92,8 @@ export declare function unlink(path: string, cb?: BFSOneArgCallback): void;
|
|
|
75
92
|
* @param mode defaults to `0644`
|
|
76
93
|
* @param callback
|
|
77
94
|
*/
|
|
78
|
-
export declare function open(path:
|
|
79
|
-
export declare function open(path:
|
|
95
|
+
export declare function open(path: PathLike, flag: string, cb?: TwoArgCallback<number>): void;
|
|
96
|
+
export declare function open(path: PathLike, flag: string, mode: number | string, cb?: TwoArgCallback<number>): void;
|
|
80
97
|
/**
|
|
81
98
|
* Asynchronously reads the entire contents of a file.
|
|
82
99
|
* @example Usage example
|
|
@@ -90,15 +107,15 @@ export declare function open(path: string, flag: string, mode: number | string,
|
|
|
90
107
|
* @option options [String] flag Defaults to `'r'`.
|
|
91
108
|
* @param callback If no encoding is specified, then the raw buffer is returned.
|
|
92
109
|
*/
|
|
93
|
-
export declare function readFile(filename:
|
|
94
|
-
export declare function readFile(filename:
|
|
110
|
+
export declare function readFile(filename: PathLike, cb: TwoArgCallback<Uint8Array>): void;
|
|
111
|
+
export declare function readFile(filename: PathLike, options: {
|
|
95
112
|
flag?: string;
|
|
96
|
-
}, callback?:
|
|
97
|
-
export declare function readFile(filename:
|
|
113
|
+
}, callback?: TwoArgCallback<Uint8Array>): void;
|
|
114
|
+
export declare function readFile(filename: PathLike, options: {
|
|
98
115
|
encoding: string;
|
|
99
116
|
flag?: string;
|
|
100
|
-
}, callback?:
|
|
101
|
-
export declare function readFile(filename:
|
|
117
|
+
}, callback?: TwoArgCallback<string>): void;
|
|
118
|
+
export declare function readFile(filename: PathLike, encoding: string, cb: TwoArgCallback<string>): void;
|
|
102
119
|
/**
|
|
103
120
|
* Asynchronously writes data to a file, replacing the file if it already
|
|
104
121
|
* exists.
|
|
@@ -118,13 +135,13 @@ export declare function readFile(filename: string, encoding: string, cb: BFSCall
|
|
|
118
135
|
* @option options [String] flag Defaults to `'w'`.
|
|
119
136
|
* @param callback
|
|
120
137
|
*/
|
|
121
|
-
export declare function writeFile(filename:
|
|
122
|
-
export declare function writeFile(filename:
|
|
123
|
-
export declare function writeFile(filename:
|
|
138
|
+
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?: {
|
|
124
141
|
encoding?: string;
|
|
125
142
|
mode?: string | number;
|
|
126
143
|
flag?: string;
|
|
127
|
-
}, cb?:
|
|
144
|
+
}, cb?: NoArgCallback): void;
|
|
128
145
|
/**
|
|
129
146
|
* Asynchronously append data to a file, creating the file if it not yet
|
|
130
147
|
* exists.
|
|
@@ -142,13 +159,13 @@ export declare function writeFile(filename: string, data: FileContents, options?
|
|
|
142
159
|
* @option options [String] flag Defaults to `'a'`.
|
|
143
160
|
* @param callback
|
|
144
161
|
*/
|
|
145
|
-
export declare function appendFile(filename:
|
|
146
|
-
export declare function appendFile(filename:
|
|
162
|
+
export declare function appendFile(filename: PathLike, data: FileContents, cb?: NoArgCallback): void;
|
|
163
|
+
export declare function appendFile(filename: PathLike, data: FileContents, options?: {
|
|
147
164
|
encoding?: string;
|
|
148
165
|
mode?: number | string;
|
|
149
166
|
flag?: string;
|
|
150
|
-
}, cb?:
|
|
151
|
-
export declare function appendFile(filename:
|
|
167
|
+
}, cb?: NoArgCallback): void;
|
|
168
|
+
export declare function appendFile(filename: PathLike, data: FileContents, encoding?: string, cb?: NoArgCallback): void;
|
|
152
169
|
/**
|
|
153
170
|
* Asynchronous `fstat`.
|
|
154
171
|
* `fstat()` is identical to `stat()`, except that the file to be stat-ed is
|
|
@@ -156,33 +173,40 @@ export declare function appendFile(filename: string, data: FileContents, encodin
|
|
|
156
173
|
* @param fd
|
|
157
174
|
* @param callback
|
|
158
175
|
*/
|
|
159
|
-
export declare function fstat(fd: number, cb
|
|
176
|
+
export declare function fstat(fd: number, cb: TwoArgCallback<Stats>): void;
|
|
177
|
+
export declare function fstat(fd: number, options: StatOptions & {
|
|
178
|
+
bigint?: false;
|
|
179
|
+
}, cb: TwoArgCallback<Stats>): void;
|
|
180
|
+
export declare function fstat(fd: number, options: StatOptions & {
|
|
181
|
+
bigint: true;
|
|
182
|
+
}, cb: TwoArgCallback<BigIntStats>): void;
|
|
183
|
+
export declare function fstat(fd: number, options: StatOptions, cb: TwoArgCallback<Stats | BigIntStats>): void;
|
|
160
184
|
/**
|
|
161
185
|
* Asynchronous close.
|
|
162
186
|
* @param fd
|
|
163
187
|
* @param callback
|
|
164
188
|
*/
|
|
165
|
-
export declare function close(fd: number, cb?:
|
|
189
|
+
export declare function close(fd: number, cb?: NoArgCallback): void;
|
|
166
190
|
/**
|
|
167
191
|
* Asynchronous ftruncate.
|
|
168
192
|
* @param fd
|
|
169
193
|
* @param len
|
|
170
194
|
* @param callback
|
|
171
195
|
*/
|
|
172
|
-
export declare function ftruncate(fd: number, cb?:
|
|
173
|
-
export declare function ftruncate(fd: number, len?: number, cb?:
|
|
196
|
+
export declare function ftruncate(fd: number, cb?: NoArgCallback): void;
|
|
197
|
+
export declare function ftruncate(fd: number, len?: number, cb?: NoArgCallback): void;
|
|
174
198
|
/**
|
|
175
199
|
* Asynchronous fsync.
|
|
176
200
|
* @param fd
|
|
177
201
|
* @param callback
|
|
178
202
|
*/
|
|
179
|
-
export declare function fsync(fd: number, cb?:
|
|
203
|
+
export declare function fsync(fd: number, cb?: NoArgCallback): void;
|
|
180
204
|
/**
|
|
181
205
|
* Asynchronous fdatasync.
|
|
182
206
|
* @param fd
|
|
183
207
|
* @param callback
|
|
184
208
|
*/
|
|
185
|
-
export declare function fdatasync(fd: number, cb?:
|
|
209
|
+
export declare function fdatasync(fd: number, cb?: NoArgCallback): void;
|
|
186
210
|
/**
|
|
187
211
|
* Write buffer to the file specified by `fd`.
|
|
188
212
|
* Note that it is unsafe to use fs.write multiple times on the same file
|
|
@@ -197,11 +221,11 @@ export declare function fdatasync(fd: number, cb?: BFSOneArgCallback): void;
|
|
|
197
221
|
* the current position.
|
|
198
222
|
* @param callback The number specifies the number of bytes written into the file.
|
|
199
223
|
*/
|
|
200
|
-
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, cb?:
|
|
201
|
-
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, position: number | null, cb?:
|
|
202
|
-
export declare function write(fd: number, data: FileContents, cb?:
|
|
203
|
-
export declare function write(fd: number, data: FileContents, position: number | null, cb?:
|
|
204
|
-
export declare function write(fd: number, data: FileContents, position: number | null, encoding: BufferEncoding, cb?:
|
|
224
|
+
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, cb?: ThreeArgCallback<number, Uint8Array>): void;
|
|
225
|
+
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, position: number | null, cb?: ThreeArgCallback<number, Uint8Array>): void;
|
|
226
|
+
export declare function write(fd: number, data: FileContents, cb?: ThreeArgCallback<number, string>): void;
|
|
227
|
+
export declare function write(fd: number, data: FileContents, position: number | null, cb?: ThreeArgCallback<number, string>): void;
|
|
228
|
+
export declare function write(fd: number, data: FileContents, position: number | null, encoding: BufferEncoding, cb?: ThreeArgCallback<number, string>): void;
|
|
205
229
|
/**
|
|
206
230
|
* Read data from the file specified by `fd`.
|
|
207
231
|
* @param buffer The buffer that the data will be
|
|
@@ -214,7 +238,7 @@ export declare function write(fd: number, data: FileContents, position: number |
|
|
|
214
238
|
* position.
|
|
215
239
|
* @param callback The number is the number of bytes read
|
|
216
240
|
*/
|
|
217
|
-
export declare function read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?:
|
|
241
|
+
export declare function read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: ThreeArgCallback<number, Uint8Array>): void;
|
|
218
242
|
/**
|
|
219
243
|
* Asynchronous `fchown`.
|
|
220
244
|
* @param fd
|
|
@@ -222,14 +246,14 @@ export declare function read(fd: number, buffer: Uint8Array, offset: number, len
|
|
|
222
246
|
* @param gid
|
|
223
247
|
* @param callback
|
|
224
248
|
*/
|
|
225
|
-
export declare function fchown(fd: number, uid: number, gid: number, cb?:
|
|
249
|
+
export declare function fchown(fd: number, uid: number, gid: number, cb?: NoArgCallback): void;
|
|
226
250
|
/**
|
|
227
251
|
* Asynchronous `fchmod`.
|
|
228
252
|
* @param fd
|
|
229
253
|
* @param mode
|
|
230
254
|
* @param callback
|
|
231
255
|
*/
|
|
232
|
-
export declare function fchmod(fd: number, mode: string | number, cb:
|
|
256
|
+
export declare function fchmod(fd: number, mode: string | number, cb: NoArgCallback): void;
|
|
233
257
|
/**
|
|
234
258
|
* Change the file timestamps of a file referenced by the supplied file
|
|
235
259
|
* descriptor.
|
|
@@ -238,20 +262,20 @@ export declare function fchmod(fd: number, mode: string | number, cb: BFSOneArgC
|
|
|
238
262
|
* @param mtime
|
|
239
263
|
* @param callback
|
|
240
264
|
*/
|
|
241
|
-
export declare function futimes(fd: number, atime: number | Date, mtime: number | Date, cb?:
|
|
265
|
+
export declare function futimes(fd: number, atime: number | Date, mtime: number | Date, cb?: NoArgCallback): void;
|
|
242
266
|
/**
|
|
243
267
|
* Asynchronous `rmdir`.
|
|
244
268
|
* @param path
|
|
245
269
|
* @param callback
|
|
246
270
|
*/
|
|
247
|
-
export declare function rmdir(path:
|
|
271
|
+
export declare function rmdir(path: PathLike, cb?: NoArgCallback): void;
|
|
248
272
|
/**
|
|
249
273
|
* Asynchronous `mkdir`.
|
|
250
274
|
* @param path
|
|
251
275
|
* @param mode defaults to `0777`
|
|
252
276
|
* @param callback
|
|
253
277
|
*/
|
|
254
|
-
export declare function mkdir(path:
|
|
278
|
+
export declare function mkdir(path: PathLike, mode?: any, cb?: NoArgCallback): void;
|
|
255
279
|
/**
|
|
256
280
|
* Asynchronous `readdir`. Reads the contents of a directory.
|
|
257
281
|
* The callback gets two arguments `(err, files)` where `files` is an array of
|
|
@@ -259,14 +283,20 @@ export declare function mkdir(path: string, mode?: any, cb?: BFSOneArgCallback):
|
|
|
259
283
|
* @param path
|
|
260
284
|
* @param callback
|
|
261
285
|
*/
|
|
262
|
-
export declare function readdir(path:
|
|
286
|
+
export declare function readdir(path: PathLike, cb: TwoArgCallback<string[]>): void;
|
|
287
|
+
export declare function readdir(path: PathLike, options: {
|
|
288
|
+
withFileTypes?: false;
|
|
289
|
+
}, cb: TwoArgCallback<string[]>): void;
|
|
290
|
+
export declare function readdir(path: PathLike, options: {
|
|
291
|
+
withFileTypes: true;
|
|
292
|
+
}, cb: TwoArgCallback<Dirent[]>): void;
|
|
263
293
|
/**
|
|
264
294
|
* Asynchronous `link`.
|
|
265
295
|
* @param srcpath
|
|
266
296
|
* @param dstpath
|
|
267
297
|
* @param callback
|
|
268
298
|
*/
|
|
269
|
-
export declare function link(srcpath:
|
|
299
|
+
export declare function link(srcpath: PathLike, dstpath: PathLike, cb?: NoArgCallback): void;
|
|
270
300
|
/**
|
|
271
301
|
* Asynchronous `symlink`.
|
|
272
302
|
* @param srcpath
|
|
@@ -274,14 +304,17 @@ export declare function link(srcpath: string, dstpath: string, cb?: BFSOneArgCal
|
|
|
274
304
|
* @param type can be either `'dir'` or `'file'` (default is `'file'`)
|
|
275
305
|
* @param callback
|
|
276
306
|
*/
|
|
277
|
-
export declare function symlink(srcpath:
|
|
278
|
-
export declare function symlink(srcpath:
|
|
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;
|
|
279
309
|
/**
|
|
280
310
|
* Asynchronous readlink.
|
|
281
311
|
* @param path
|
|
282
312
|
* @param callback
|
|
283
313
|
*/
|
|
284
|
-
export declare function readlink(path:
|
|
314
|
+
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;
|
|
285
318
|
/**
|
|
286
319
|
* Asynchronous `chown`.
|
|
287
320
|
* @param path
|
|
@@ -289,7 +322,7 @@ export declare function readlink(path: string, cb?: BFSCallback<string>): void;
|
|
|
289
322
|
* @param gid
|
|
290
323
|
* @param callback
|
|
291
324
|
*/
|
|
292
|
-
export declare function chown(path:
|
|
325
|
+
export declare function chown(path: PathLike, uid: number, gid: number, cb?: NoArgCallback): void;
|
|
293
326
|
/**
|
|
294
327
|
* Asynchronous `lchown`.
|
|
295
328
|
* @param path
|
|
@@ -297,21 +330,21 @@ export declare function chown(path: string, uid: number, gid: number, cb?: BFSOn
|
|
|
297
330
|
* @param gid
|
|
298
331
|
* @param callback
|
|
299
332
|
*/
|
|
300
|
-
export declare function lchown(path:
|
|
333
|
+
export declare function lchown(path: PathLike, uid: number, gid: number, cb?: NoArgCallback): void;
|
|
301
334
|
/**
|
|
302
335
|
* Asynchronous `chmod`.
|
|
303
336
|
* @param path
|
|
304
337
|
* @param mode
|
|
305
338
|
* @param callback
|
|
306
339
|
*/
|
|
307
|
-
export declare function chmod(path:
|
|
340
|
+
export declare function chmod(path: PathLike, mode: number | string, cb?: NoArgCallback): void;
|
|
308
341
|
/**
|
|
309
342
|
* Asynchronous `lchmod`.
|
|
310
343
|
* @param path
|
|
311
344
|
* @param mode
|
|
312
345
|
* @param callback
|
|
313
346
|
*/
|
|
314
|
-
export declare function lchmod(path:
|
|
347
|
+
export declare function lchmod(path: PathLike, mode: number | string, cb?: NoArgCallback): void;
|
|
315
348
|
/**
|
|
316
349
|
* Change file timestamps of the file referenced by the supplied path.
|
|
317
350
|
* @param path
|
|
@@ -319,7 +352,7 @@ export declare function lchmod(path: string, mode: number | string, cb?: BFSOneA
|
|
|
319
352
|
* @param mtime
|
|
320
353
|
* @param callback
|
|
321
354
|
*/
|
|
322
|
-
export declare function utimes(path:
|
|
355
|
+
export declare function utimes(path: PathLike, atime: number | Date, mtime: number | Date, cb?: NoArgCallback): void;
|
|
323
356
|
/**
|
|
324
357
|
* Change file timestamps of the file referenced by the supplied path.
|
|
325
358
|
* @param path
|
|
@@ -327,56 +360,60 @@ export declare function utimes(path: string, atime: number | Date, mtime: number
|
|
|
327
360
|
* @param mtime
|
|
328
361
|
* @param callback
|
|
329
362
|
*/
|
|
330
|
-
export declare function lutimes(path:
|
|
363
|
+
export declare function lutimes(path: PathLike, atime: number | Date, mtime: number | Date, cb?: NoArgCallback): void;
|
|
331
364
|
/**
|
|
332
365
|
* Asynchronous `realpath`. The callback gets two arguments
|
|
333
366
|
* `(err, resolvedPath)`. May use `process.cwd` to resolve relative paths.
|
|
334
367
|
*
|
|
335
368
|
* @example Usage example
|
|
336
|
-
*
|
|
337
|
-
* fs.realpath('/etc/passwd', cache, function (err, resolvedPath) {
|
|
369
|
+
* fs.realpath('/etc/passwd', function (err, resolvedPath) {
|
|
338
370
|
* if (err) throw err;
|
|
339
371
|
* console.log(resolvedPath);
|
|
340
372
|
* });
|
|
341
373
|
*
|
|
342
374
|
* @param path
|
|
343
|
-
* @param cache An object literal of mapped paths that can be used to
|
|
344
|
-
* force a specific path resolution or avoid additional `fs.stat` calls for
|
|
345
|
-
* known real paths.
|
|
346
375
|
* @param callback
|
|
347
376
|
*/
|
|
348
|
-
export declare function realpath(path:
|
|
349
|
-
export declare function realpath(path:
|
|
350
|
-
[path: string]: string;
|
|
351
|
-
}, cb: BFSCallback<string>): void;
|
|
377
|
+
export declare function realpath(path: PathLike, cb?: TwoArgCallback<string>): void;
|
|
378
|
+
export declare function realpath(path: PathLike, options: BaseEncodingOptions, cb: TwoArgCallback<string>): void;
|
|
352
379
|
/**
|
|
353
380
|
* Asynchronous `access`.
|
|
354
381
|
* @param path
|
|
355
382
|
* @param mode
|
|
356
383
|
* @param callback
|
|
357
384
|
*/
|
|
358
|
-
export declare function access(path:
|
|
359
|
-
export declare function access(path:
|
|
360
|
-
export declare function watchFile(filename:
|
|
361
|
-
export declare function watchFile(filename:
|
|
385
|
+
export declare function access(path: PathLike, cb: NoArgCallback): void;
|
|
386
|
+
export declare function access(path: PathLike, mode: number, cb: NoArgCallback): void;
|
|
387
|
+
export declare function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): void;
|
|
388
|
+
export declare function watchFile(filename: PathLike, options: {
|
|
362
389
|
persistent?: boolean;
|
|
363
390
|
interval?: number;
|
|
364
391
|
}, listener: (curr: Stats, prev: Stats) => void): void;
|
|
365
|
-
export declare function unwatchFile(filename:
|
|
366
|
-
export declare function watch(filename:
|
|
367
|
-
export declare function watch(filename:
|
|
392
|
+
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;
|
|
394
|
+
export declare function watch(filename: PathLike, options: {
|
|
368
395
|
persistent?: boolean;
|
|
369
396
|
}, listener?: (event: string, filename: string) => any): FSWatcher;
|
|
370
|
-
export declare function createReadStream(path:
|
|
397
|
+
export declare function createReadStream(path: PathLike, options?: {
|
|
371
398
|
flags?: string;
|
|
372
399
|
encoding?: string;
|
|
373
400
|
fd?: number;
|
|
374
401
|
mode?: number;
|
|
375
402
|
autoClose?: boolean;
|
|
376
403
|
}): ReadStream;
|
|
377
|
-
export declare function createWriteStream(path:
|
|
404
|
+
export declare function createWriteStream(path: PathLike, options?: {
|
|
378
405
|
flags?: string;
|
|
379
406
|
encoding?: string;
|
|
380
407
|
fd?: number;
|
|
381
408
|
mode?: number;
|
|
382
409
|
}): WriteStream;
|
|
410
|
+
export declare function rm(path: PathLike): void;
|
|
411
|
+
export declare function mkdtemp(path: PathLike): void;
|
|
412
|
+
export declare function copyFile(src: PathLike, dest: PathLike, callback: NoArgCallback): void;
|
|
413
|
+
export declare function copyFile(src: PathLike, dest: PathLike, flags: number, callback: NoArgCallback): void;
|
|
414
|
+
export declare function readv(path: PathLike): void;
|
|
415
|
+
type writevCallback = ThreeArgCallback<number, Uint8Array[]>;
|
|
416
|
+
export declare function writev(fd: number, buffers: Uint8Array[], cb: writevCallback): void;
|
|
417
|
+
export declare function writev(fd: number, buffers: Uint8Array[], position: number, cb: writevCallback): void;
|
|
418
|
+
export declare function opendir(path: PathLike): void;
|
|
419
|
+
export {};
|
|
@@ -32,29 +32,19 @@ export function exists(path, cb = nop) {
|
|
|
32
32
|
.then(cb)
|
|
33
33
|
.catch(() => cb(false));
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
* @param path
|
|
38
|
-
* @param callback
|
|
39
|
-
*/
|
|
40
|
-
export function stat(path, cb = nop) {
|
|
35
|
+
export function stat(path, options, callback = nop) {
|
|
36
|
+
callback = typeof options == 'function' ? options : callback;
|
|
41
37
|
promises
|
|
42
|
-
.stat(path)
|
|
43
|
-
.then(stats =>
|
|
44
|
-
.catch(
|
|
38
|
+
.stat(path, typeof options != 'function' ? options : {})
|
|
39
|
+
.then(stats => callback(null, stats))
|
|
40
|
+
.catch(callback);
|
|
45
41
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* `lstat()` is identical to `stat()`, except that if path is a symbolic link,
|
|
49
|
-
* then the link itself is stat-ed, not the file that it refers to.
|
|
50
|
-
* @param path
|
|
51
|
-
* @param callback
|
|
52
|
-
*/
|
|
53
|
-
export function lstat(path, cb = nop) {
|
|
42
|
+
export function lstat(path, options, callback = nop) {
|
|
43
|
+
callback = typeof options == 'function' ? options : callback;
|
|
54
44
|
promises
|
|
55
|
-
.lstat(path)
|
|
56
|
-
.then(stats =>
|
|
57
|
-
.catch(
|
|
45
|
+
.lstat(path, typeof options != 'function' ? options : {})
|
|
46
|
+
.then(stats => callback(null, stats))
|
|
47
|
+
.catch(callback);
|
|
58
48
|
}
|
|
59
49
|
export function truncate(path, arg2 = 0, cb = nop) {
|
|
60
50
|
cb = typeof arg2 === 'function' ? arg2 : cb;
|
|
@@ -95,16 +85,10 @@ export function appendFile(filename, data, arg3, cb = nop) {
|
|
|
95
85
|
cb = typeof arg3 === 'function' ? arg3 : cb;
|
|
96
86
|
promises.appendFile(filename, data, typeof arg3 === 'function' ? null : arg3);
|
|
97
87
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
* `fstat()` is identical to `stat()`, except that the file to be stat-ed is
|
|
101
|
-
* specified by the file descriptor `fd`.
|
|
102
|
-
* @param fd
|
|
103
|
-
* @param callback
|
|
104
|
-
*/
|
|
105
|
-
export function fstat(fd, cb = nop) {
|
|
88
|
+
export function fstat(fd, options, cb = nop) {
|
|
89
|
+
cb = typeof options == 'function' ? options : cb;
|
|
106
90
|
promises
|
|
107
|
-
.fstat(fd)
|
|
91
|
+
.fstat(fd, typeof options != 'function' ? options : {})
|
|
108
92
|
.then(stats => cb(null, stats))
|
|
109
93
|
.catch(cb);
|
|
110
94
|
}
|
|
@@ -270,16 +254,12 @@ export function mkdir(path, mode, cb = nop) {
|
|
|
270
254
|
.then(() => cb())
|
|
271
255
|
.catch(cb);
|
|
272
256
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
* the names of the files in the directory excluding `'.'` and `'..'`.
|
|
277
|
-
* @param path
|
|
278
|
-
* @param callback
|
|
279
|
-
*/
|
|
280
|
-
export function readdir(path, cb = nop) {
|
|
257
|
+
export function readdir(path, _options, cb = nop) {
|
|
258
|
+
cb = typeof _options == 'function' ? _options : cb;
|
|
259
|
+
const options = typeof _options != 'function' ? _options : {};
|
|
281
260
|
promises
|
|
282
|
-
.readdir(path)
|
|
261
|
+
.readdir(path, options)
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
283
263
|
.then(entries => cb(null, entries))
|
|
284
264
|
.catch(cb);
|
|
285
265
|
}
|
|
@@ -303,16 +283,12 @@ export function symlink(srcpath, dstpath, arg3, cb = nop) {
|
|
|
303
283
|
.then(() => cb())
|
|
304
284
|
.catch(cb);
|
|
305
285
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
* @param path
|
|
309
|
-
* @param callback
|
|
310
|
-
*/
|
|
311
|
-
export function readlink(path, cb = nop) {
|
|
286
|
+
export function readlink(path, options, callback = nop) {
|
|
287
|
+
callback = typeof options == 'function' ? options : callback;
|
|
312
288
|
promises
|
|
313
289
|
.readlink(path)
|
|
314
|
-
.then(result =>
|
|
315
|
-
.catch(
|
|
290
|
+
.then(result => callback(null, result))
|
|
291
|
+
.catch(callback);
|
|
316
292
|
}
|
|
317
293
|
/**
|
|
318
294
|
* Asynchronous `chown`.
|
|
@@ -391,7 +367,6 @@ export function lutimes(path, atime, mtime, cb = nop) {
|
|
|
391
367
|
.catch(cb);
|
|
392
368
|
}
|
|
393
369
|
export function realpath(path, arg2, cb = nop) {
|
|
394
|
-
const cache = typeof arg2 === 'object' ? arg2 : {};
|
|
395
370
|
cb = typeof arg2 === 'function' ? arg2 : cb;
|
|
396
371
|
promises
|
|
397
372
|
.realpath(path, typeof arg2 === 'function' ? null : arg2)
|
|
@@ -421,3 +396,21 @@ export function createReadStream(path, options) {
|
|
|
421
396
|
export function createWriteStream(path, options) {
|
|
422
397
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
423
398
|
}
|
|
399
|
+
export function rm(path) {
|
|
400
|
+
new ApiError(ErrorCode.ENOTSUP);
|
|
401
|
+
}
|
|
402
|
+
export function mkdtemp(path) {
|
|
403
|
+
new ApiError(ErrorCode.ENOTSUP);
|
|
404
|
+
}
|
|
405
|
+
export function copyFile(src, dest, flags, callback) {
|
|
406
|
+
new ApiError(ErrorCode.ENOTSUP);
|
|
407
|
+
}
|
|
408
|
+
export function readv(path) {
|
|
409
|
+
new ApiError(ErrorCode.ENOTSUP);
|
|
410
|
+
}
|
|
411
|
+
export function writev(fd, buffers, position, cb) {
|
|
412
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
413
|
+
}
|
|
414
|
+
export function opendir(path) {
|
|
415
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
416
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type { Dirent as _Dirent, Dir as _Dir } from 'fs';
|
|
3
|
+
import { NoArgCallback, TwoArgCallback } from '../filesystem.js';
|
|
4
|
+
import { Stats } from '../stats.js';
|
|
5
|
+
export declare class Dirent implements _Dirent {
|
|
6
|
+
name: string;
|
|
7
|
+
protected stats: Stats;
|
|
8
|
+
constructor(name: string, stats: Stats);
|
|
9
|
+
isFile(): boolean;
|
|
10
|
+
isDirectory(): boolean;
|
|
11
|
+
isBlockDevice(): boolean;
|
|
12
|
+
isCharacterDevice(): boolean;
|
|
13
|
+
isSymbolicLink(): boolean;
|
|
14
|
+
isFIFO(): boolean;
|
|
15
|
+
isSocket(): boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A class representing a directory stream.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Dir implements _Dir {
|
|
21
|
+
readonly path: string;
|
|
22
|
+
protected closed: boolean;
|
|
23
|
+
protected checkClosed(): void;
|
|
24
|
+
protected _entries: Dirent[];
|
|
25
|
+
constructor(path: string);
|
|
26
|
+
/**
|
|
27
|
+
* Asynchronously close the directory's underlying resource handle.
|
|
28
|
+
* Subsequent reads will result in errors.
|
|
29
|
+
*/
|
|
30
|
+
close(): Promise<void>;
|
|
31
|
+
close(cb: NoArgCallback): void;
|
|
32
|
+
/**
|
|
33
|
+
* Synchronously close the directory's underlying resource handle.
|
|
34
|
+
* Subsequent reads will result in errors.
|
|
35
|
+
*/
|
|
36
|
+
closeSync(): void;
|
|
37
|
+
protected _read(): Promise<Dirent | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Asynchronously read the next directory entry via `readdir(3)` as an `Dirent`.
|
|
40
|
+
* After the read is completed, a value is returned that will be resolved with an `Dirent`, or `null` if there are no more directory entries to read.
|
|
41
|
+
* Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
|
|
42
|
+
*/
|
|
43
|
+
read(): Promise<Dirent | null>;
|
|
44
|
+
read(cb: TwoArgCallback<Dirent | null>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Synchronously read the next directory entry via `readdir(3)` as a `Dirent`.
|
|
47
|
+
* If there are no more directory entries to read, null will be returned.
|
|
48
|
+
* Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
|
|
49
|
+
*/
|
|
50
|
+
readSync(): Dirent | null;
|
|
51
|
+
/**
|
|
52
|
+
* Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
|
|
53
|
+
*/
|
|
54
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<Dirent>;
|
|
55
|
+
}
|