@zenfs/core 0.0.1
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/README.md +293 -0
- package/dist/ApiError.d.ts +86 -0
- package/dist/ApiError.js +135 -0
- package/dist/backends/AsyncMirror.d.ts +102 -0
- package/dist/backends/AsyncMirror.js +252 -0
- package/dist/backends/AsyncStore.d.ts +166 -0
- package/dist/backends/AsyncStore.js +620 -0
- package/dist/backends/FolderAdapter.d.ts +52 -0
- package/dist/backends/FolderAdapter.js +184 -0
- package/dist/backends/InMemory.d.ts +25 -0
- package/dist/backends/InMemory.js +46 -0
- package/dist/backends/Locked.d.ts +64 -0
- package/dist/backends/Locked.js +302 -0
- package/dist/backends/OverlayFS.d.ts +120 -0
- package/dist/backends/OverlayFS.js +749 -0
- package/dist/backends/SyncStore.d.ts +223 -0
- package/dist/backends/SyncStore.js +479 -0
- package/dist/backends/backend.d.ts +73 -0
- package/dist/backends/backend.js +14 -0
- package/dist/backends/index.d.ts +11 -0
- package/dist/backends/index.js +15 -0
- package/dist/browser.min.js +12 -0
- package/dist/browser.min.js.map +7 -0
- package/dist/cred.d.ts +14 -0
- package/dist/cred.js +15 -0
- package/dist/emulation/callbacks.d.ts +382 -0
- package/dist/emulation/callbacks.js +422 -0
- package/dist/emulation/constants.d.ts +101 -0
- package/dist/emulation/constants.js +110 -0
- package/dist/emulation/fs.d.ts +7 -0
- package/dist/emulation/fs.js +5 -0
- package/dist/emulation/index.d.ts +5 -0
- package/dist/emulation/index.js +7 -0
- package/dist/emulation/promises.d.ts +309 -0
- package/dist/emulation/promises.js +521 -0
- package/dist/emulation/shared.d.ts +62 -0
- package/dist/emulation/shared.js +192 -0
- package/dist/emulation/sync.d.ts +278 -0
- package/dist/emulation/sync.js +392 -0
- package/dist/file.d.ts +449 -0
- package/dist/file.js +576 -0
- package/dist/filesystem.d.ts +367 -0
- package/dist/filesystem.js +542 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +113 -0
- package/dist/inode.d.ts +51 -0
- package/dist/inode.js +112 -0
- package/dist/mutex.d.ts +12 -0
- package/dist/mutex.js +48 -0
- package/dist/stats.d.ts +98 -0
- package/dist/stats.js +226 -0
- package/dist/utils.d.ts +52 -0
- package/dist/utils.js +261 -0
- package/license.md +122 -0
- package/package.json +61 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { ReadStream, WriteStream, FSWatcher, symlink as _symlink } from 'node:fs';
|
|
4
|
+
import * as constants from './constants';
|
|
5
|
+
export { constants };
|
|
6
|
+
import { FileContents } from '../filesystem';
|
|
7
|
+
import { Stats } from '../stats';
|
|
8
|
+
/**
|
|
9
|
+
* Renames a file
|
|
10
|
+
* @param oldPath
|
|
11
|
+
* @param newPath
|
|
12
|
+
*/
|
|
13
|
+
export declare function rename(oldPath: string, newPath: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Test whether or not the given path exists by checking with the file system.
|
|
16
|
+
* @param path
|
|
17
|
+
*/
|
|
18
|
+
export declare function exists(path: string): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* `stat`.
|
|
21
|
+
* @param path
|
|
22
|
+
* @returns Stats
|
|
23
|
+
*/
|
|
24
|
+
export declare function stat(path: string): Promise<Stats>;
|
|
25
|
+
/**
|
|
26
|
+
* `lstat`.
|
|
27
|
+
* `lstat()` is identical to `stat()`, except that if path is a symbolic link,
|
|
28
|
+
* then the link itself is stat-ed, not the file that it refers to.
|
|
29
|
+
* @param path
|
|
30
|
+
* @return [ZenFS.node.fs.Stats]
|
|
31
|
+
*/
|
|
32
|
+
export declare function lstat(path: string): Promise<Stats>;
|
|
33
|
+
/**
|
|
34
|
+
* `truncate`.
|
|
35
|
+
* @param path
|
|
36
|
+
* @param len
|
|
37
|
+
*/
|
|
38
|
+
export declare function truncate(path: string, len?: number): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* `unlink`.
|
|
41
|
+
* @param path
|
|
42
|
+
*/
|
|
43
|
+
export declare function unlink(path: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* file open.
|
|
46
|
+
* @see http://www.manpagez.com/man/2/open/
|
|
47
|
+
* @param path
|
|
48
|
+
* @param flags
|
|
49
|
+
* @param mode defaults to `0644`
|
|
50
|
+
*/
|
|
51
|
+
export declare function open(path: string, flag: string, mode?: number | string): Promise<number>;
|
|
52
|
+
/**
|
|
53
|
+
* Synchronously reads the entire contents of a file.
|
|
54
|
+
* @param filename
|
|
55
|
+
* @param options
|
|
56
|
+
* @option options [String] encoding The string encoding for the file contents. Defaults to `null`.
|
|
57
|
+
* @option options [String] flag Defaults to `'r'`.
|
|
58
|
+
* @return [String | ZenFS.node.Buffer]
|
|
59
|
+
*/
|
|
60
|
+
export declare function readFile(filename: string, options?: {
|
|
61
|
+
flag?: string;
|
|
62
|
+
}): Promise<Buffer>;
|
|
63
|
+
export declare function readFile(filename: string, options: {
|
|
64
|
+
encoding: string;
|
|
65
|
+
flag?: string;
|
|
66
|
+
}): Promise<string>;
|
|
67
|
+
export declare function readFile(filename: string, encoding: string): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Synchronously writes data to a file, replacing the file if it already
|
|
70
|
+
* exists.
|
|
71
|
+
*
|
|
72
|
+
* The encoding option is ignored if data is a buffer.
|
|
73
|
+
* @param filename
|
|
74
|
+
* @param data
|
|
75
|
+
* @param options
|
|
76
|
+
* @option options [String] encoding Defaults to `'utf8'`.
|
|
77
|
+
* @option options [Number] mode Defaults to `0644`.
|
|
78
|
+
* @option options [String] flag Defaults to `'w'`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function writeFile(filename: string, data: FileContents, options?: {
|
|
81
|
+
encoding?: string;
|
|
82
|
+
mode?: number | string;
|
|
83
|
+
flag?: string;
|
|
84
|
+
}): Promise<void>;
|
|
85
|
+
export declare function writeFile(filename: string, data: FileContents, encoding?: string): Promise<void>;
|
|
86
|
+
export declare function writeFile(filename: string, data: FileContents, options?: {
|
|
87
|
+
encoding?: string;
|
|
88
|
+
mode?: number | string;
|
|
89
|
+
flag?: string;
|
|
90
|
+
} | string): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Asynchronously append data to a file, creating the file if it not yet
|
|
93
|
+
* exists.
|
|
94
|
+
*
|
|
95
|
+
* @example Usage example
|
|
96
|
+
* fs.appendFile('message.txt', 'data to append', function (err) {
|
|
97
|
+
* if (err) throw err;
|
|
98
|
+
* console.log('The "data to append" was appended to file!');
|
|
99
|
+
* });
|
|
100
|
+
* @param filename
|
|
101
|
+
* @param data
|
|
102
|
+
* @param options
|
|
103
|
+
* @option options [String] encoding Defaults to `'utf8'`.
|
|
104
|
+
* @option options [Number] mode Defaults to `0644`.
|
|
105
|
+
* @option options [String] flag Defaults to `'a'`.
|
|
106
|
+
*/
|
|
107
|
+
export declare function appendFile(filename: string, data: FileContents, options?: {
|
|
108
|
+
encoding?: string;
|
|
109
|
+
mode?: number | string;
|
|
110
|
+
flag?: string;
|
|
111
|
+
}): Promise<void>;
|
|
112
|
+
export declare function appendFile(filename: string, data: FileContents, encoding?: string): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* `fstat`.
|
|
115
|
+
* `fstat()` is identical to `stat()`, except that the file to be stat-ed is
|
|
116
|
+
* specified by the file descriptor `fd`.
|
|
117
|
+
* @param fd
|
|
118
|
+
* @return [ZenFS.node.fs.Stats]
|
|
119
|
+
*/
|
|
120
|
+
export declare function fstat(fd: number): Promise<Stats>;
|
|
121
|
+
/**
|
|
122
|
+
* close.
|
|
123
|
+
* @param fd
|
|
124
|
+
*/
|
|
125
|
+
export declare function close(fd: number): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* ftruncate.
|
|
128
|
+
* @param fd
|
|
129
|
+
* @param len
|
|
130
|
+
*/
|
|
131
|
+
export declare function ftruncate(fd: number, len?: number): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* fsync.
|
|
134
|
+
* @param fd
|
|
135
|
+
*/
|
|
136
|
+
export declare function fsync(fd: number): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* fdatasync.
|
|
139
|
+
* @param fd
|
|
140
|
+
*/
|
|
141
|
+
export declare function fdatasync(fd: number): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Write buffer to the file specified by `fd`.
|
|
144
|
+
* Note that it is unsafe to use fs.write multiple times on the same file
|
|
145
|
+
* without waiting for it to return.
|
|
146
|
+
* @param fd
|
|
147
|
+
* @param buffer Buffer containing the data to write to
|
|
148
|
+
* the file.
|
|
149
|
+
* @param offset Offset in the buffer to start reading data from.
|
|
150
|
+
* @param length The amount of bytes to write to the file.
|
|
151
|
+
* @param position Offset from the beginning of the file where this
|
|
152
|
+
* data should be written. If position is null, the data will be written at
|
|
153
|
+
* the current position.
|
|
154
|
+
*/
|
|
155
|
+
export declare function write(fd: number, buffer: Buffer, offset: number, length: number, position?: number): Promise<number>;
|
|
156
|
+
export declare function write(fd: number, data: string, position?: number | null, encoding?: BufferEncoding): Promise<number>;
|
|
157
|
+
/**
|
|
158
|
+
* Read data from the file specified by `fd`.
|
|
159
|
+
* @param fd
|
|
160
|
+
* @param buffer The buffer that the data will be
|
|
161
|
+
* written to.
|
|
162
|
+
* @param offset The offset within the buffer where writing will
|
|
163
|
+
* start.
|
|
164
|
+
* @param length An integer specifying the number of bytes to read.
|
|
165
|
+
* @param position An integer specifying where to begin reading from
|
|
166
|
+
* in the file. If position is null, data will be read from the current file
|
|
167
|
+
* position.
|
|
168
|
+
*/
|
|
169
|
+
export declare function read(fd: number, buffer: Buffer, offset: number, length: number, position?: number): Promise<{
|
|
170
|
+
bytesRead: number;
|
|
171
|
+
buffer: Buffer;
|
|
172
|
+
}>;
|
|
173
|
+
/**
|
|
174
|
+
* `fchown`.
|
|
175
|
+
* @param fd
|
|
176
|
+
* @param uid
|
|
177
|
+
* @param gid
|
|
178
|
+
*/
|
|
179
|
+
export declare function fchown(fd: number, uid: number, gid: number): Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* `fchmod`.
|
|
182
|
+
* @param fd
|
|
183
|
+
* @param mode
|
|
184
|
+
*/
|
|
185
|
+
export declare function fchmod(fd: number, mode: number | string): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Change the file timestamps of a file referenced by the supplied file
|
|
188
|
+
* descriptor.
|
|
189
|
+
* @param fd
|
|
190
|
+
* @param atime
|
|
191
|
+
* @param mtime
|
|
192
|
+
*/
|
|
193
|
+
export declare function futimes(fd: number, atime: number | Date, mtime: number | Date): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* `rmdir`.
|
|
196
|
+
* @param path
|
|
197
|
+
*/
|
|
198
|
+
export declare function rmdir(path: string): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* `mkdir`.
|
|
201
|
+
* @param path
|
|
202
|
+
* @param mode defaults to `0777`
|
|
203
|
+
*/
|
|
204
|
+
export declare function mkdir(path: string, mode?: number | string): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* `readdir`. Reads the contents of a directory.
|
|
207
|
+
* @param path
|
|
208
|
+
* @return [String[]]
|
|
209
|
+
*/
|
|
210
|
+
export declare function readdir(path: string): Promise<string[]>;
|
|
211
|
+
/**
|
|
212
|
+
* `link`.
|
|
213
|
+
* @param srcpath
|
|
214
|
+
* @param dstpath
|
|
215
|
+
*/
|
|
216
|
+
export declare function link(srcpath: string, dstpath: string): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* `symlink`.
|
|
219
|
+
* @param srcpath
|
|
220
|
+
* @param dstpath
|
|
221
|
+
* @param type can be either `'dir'` or `'file'` (default is `'file'`)
|
|
222
|
+
*/
|
|
223
|
+
export declare function symlink(srcpath: string, dstpath: string, type?: _symlink.Type): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* readlink.
|
|
226
|
+
* @param path
|
|
227
|
+
* @return [String]
|
|
228
|
+
*/
|
|
229
|
+
export declare function readlink(path: string): Promise<string>;
|
|
230
|
+
/**
|
|
231
|
+
* `chown`.
|
|
232
|
+
* @param path
|
|
233
|
+
* @param uid
|
|
234
|
+
* @param gid
|
|
235
|
+
*/
|
|
236
|
+
export declare function chown(path: string, uid: number, gid: number): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* `lchown`.
|
|
239
|
+
* @param path
|
|
240
|
+
* @param uid
|
|
241
|
+
* @param gid
|
|
242
|
+
*/
|
|
243
|
+
export declare function lchown(path: string, uid: number, gid: number): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* `chmod`.
|
|
246
|
+
* @param path
|
|
247
|
+
* @param mode
|
|
248
|
+
*/
|
|
249
|
+
export declare function chmod(path: string, mode: string | number): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
* `lchmod`.
|
|
252
|
+
* @param path
|
|
253
|
+
* @param mode
|
|
254
|
+
*/
|
|
255
|
+
export declare function lchmod(path: string, mode: number | string): Promise<void>;
|
|
256
|
+
/**
|
|
257
|
+
* Change file timestamps of the file referenced by the supplied path.
|
|
258
|
+
* @param path
|
|
259
|
+
* @param atime
|
|
260
|
+
* @param mtime
|
|
261
|
+
*/
|
|
262
|
+
export declare function utimes(path: string, atime: number | Date, mtime: number | Date): Promise<void>;
|
|
263
|
+
/**
|
|
264
|
+
* Change file timestamps of the file referenced by the supplied path.
|
|
265
|
+
* @param path
|
|
266
|
+
* @param atime
|
|
267
|
+
* @param mtime
|
|
268
|
+
*/
|
|
269
|
+
export declare function lutimes(path: string, atime: number | Date, mtime: number | Date): Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* `realpath`.
|
|
272
|
+
* @param path
|
|
273
|
+
* @param cache An object literal of mapped paths that can be used to
|
|
274
|
+
* force a specific path resolution or avoid additional `fs.stat` calls for
|
|
275
|
+
* known real paths.
|
|
276
|
+
* @return [String]
|
|
277
|
+
*/
|
|
278
|
+
export declare function realpath(path: string, cache?: {
|
|
279
|
+
[path: string]: string;
|
|
280
|
+
}): Promise<string>;
|
|
281
|
+
export declare function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): Promise<void>;
|
|
282
|
+
export declare function watchFile(filename: string, options: {
|
|
283
|
+
persistent?: boolean;
|
|
284
|
+
interval?: number;
|
|
285
|
+
}, listener: (curr: Stats, prev: Stats) => void): Promise<void>;
|
|
286
|
+
export declare function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): Promise<void>;
|
|
287
|
+
export declare function watch(filename: string, listener?: (event: string, filename: string) => any): Promise<FSWatcher>;
|
|
288
|
+
export declare function watch(filename: string, options: {
|
|
289
|
+
persistent?: boolean;
|
|
290
|
+
}, listener?: (event: string, filename: string) => any): Promise<FSWatcher>;
|
|
291
|
+
/**
|
|
292
|
+
* `access`.
|
|
293
|
+
* @param path
|
|
294
|
+
* @param mode
|
|
295
|
+
*/
|
|
296
|
+
export declare function access(path: string, mode?: number): Promise<void>;
|
|
297
|
+
export declare function createReadStream(path: string, options?: {
|
|
298
|
+
flags?: string;
|
|
299
|
+
encoding?: string;
|
|
300
|
+
fd?: number;
|
|
301
|
+
mode?: number;
|
|
302
|
+
autoClose?: boolean;
|
|
303
|
+
}): Promise<ReadStream>;
|
|
304
|
+
export declare function createWriteStream(path: string, options?: {
|
|
305
|
+
flags?: string;
|
|
306
|
+
encoding?: string;
|
|
307
|
+
fd?: number;
|
|
308
|
+
mode?: number;
|
|
309
|
+
}): Promise<WriteStream>;
|