@zenfs/core 0.9.6 → 0.9.7
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 +4 -3
- package/dist/ApiError.js +1 -1
- package/dist/backends/AsyncStore.d.ts +3 -2
- package/dist/backends/AsyncStore.js +12 -5
- package/dist/backends/InMemory.d.ts +1 -1
- package/dist/backends/Index.d.ts +7 -10
- package/dist/backends/Index.js +7 -5
- package/dist/backends/Overlay.js +1 -1
- package/dist/backends/SyncStore.d.ts +6 -6
- package/dist/backends/SyncStore.js +4 -4
- package/dist/backends/backend.d.ts +5 -4
- package/dist/backends/backend.js +2 -2
- package/dist/browser.min.js +4 -4
- package/dist/browser.min.js.map +3 -3
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -2
- package/dist/emulation/async.d.ts +76 -77
- package/dist/emulation/async.js +42 -42
- package/dist/emulation/dir.js +6 -5
- package/dist/emulation/promises.d.ts +106 -102
- package/dist/emulation/promises.js +61 -65
- package/dist/emulation/shared.d.ts +1 -7
- package/dist/emulation/shared.js +1 -1
- package/dist/emulation/streams.js +3 -2
- package/dist/emulation/sync.d.ts +71 -64
- package/dist/emulation/sync.js +39 -40
- package/dist/file.d.ts +4 -4
- package/dist/file.js +7 -5
- package/dist/filesystem.d.ts +1 -1
- package/dist/filesystem.js +3 -0
- package/dist/mutex.js +2 -2
- package/dist/stats.d.ts +7 -7
- package/dist/stats.js +50 -10
- package/dist/utils.d.ts +5 -5
- package/dist/utils.js +4 -3
- package/package.json +3 -3
- package/readme.md +2 -2
- package/src/ApiError.ts +3 -1
- package/src/backends/AsyncStore.ts +14 -8
- package/src/backends/Index.ts +14 -10
- package/src/backends/Overlay.ts +3 -3
- package/src/backends/SyncStore.ts +8 -8
- package/src/backends/backend.ts +7 -5
- package/src/config.ts +5 -5
- package/src/emulation/async.ts +188 -196
- package/src/emulation/dir.ts +6 -6
- package/src/emulation/promises.ts +181 -173
- package/src/emulation/shared.ts +2 -9
- package/src/emulation/streams.ts +9 -8
- package/src/emulation/sync.ts +159 -159
- package/src/file.ts +11 -9
- package/src/filesystem.ts +11 -7
- package/src/mutex.ts +3 -3
- package/src/stats.ts +32 -23
- package/src/utils.ts +10 -9
- package/tsconfig.json +2 -1
package/src/emulation/shared.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function setCred(val: Cred): void {
|
|
|
17
17
|
// descriptors
|
|
18
18
|
export const fdMap: Map<number, File> = new Map();
|
|
19
19
|
let nextFd = 100;
|
|
20
|
-
export function
|
|
20
|
+
export function file2fd(file: File): number {
|
|
21
21
|
const fd = nextFd++;
|
|
22
22
|
fdMap.set(fd, file);
|
|
23
23
|
return fd;
|
|
@@ -26,7 +26,7 @@ export function fd2file(fd: number): File {
|
|
|
26
26
|
if (!fdMap.has(fd)) {
|
|
27
27
|
throw new ApiError(ErrorCode.EBADF);
|
|
28
28
|
}
|
|
29
|
-
return fdMap.get(fd)
|
|
29
|
+
return fdMap.get(fd)!;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// mounting
|
|
@@ -119,10 +119,3 @@ export function mountMapping(mountMapping: MountMapping): void {
|
|
|
119
119
|
mount(point, fs);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Types supports as path parameters.
|
|
125
|
-
*
|
|
126
|
-
* In the future, maybe support URL?
|
|
127
|
-
*/
|
|
128
|
-
export type PathLike = string;
|
package/src/emulation/streams.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type * as Node from 'fs';
|
|
2
2
|
import { Readable, Writable } from 'readable-stream';
|
|
3
3
|
import { Callback } from '../utils.js';
|
|
4
|
+
import { ApiError, ErrorCode } from '../ApiError.js';
|
|
4
5
|
|
|
5
6
|
export class ReadStream extends Readable implements Node.ReadStream {
|
|
6
7
|
close(callback: Callback = () => null): void {
|
|
@@ -9,12 +10,12 @@ export class ReadStream extends Readable implements Node.ReadStream {
|
|
|
9
10
|
super.emit('close');
|
|
10
11
|
callback();
|
|
11
12
|
} catch (err) {
|
|
12
|
-
callback(err);
|
|
13
|
+
callback(new ApiError(ErrorCode.EIO, (err as Error).toString()));
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
bytesRead: number;
|
|
16
|
-
path: string | Buffer;
|
|
17
|
-
pending: boolean;
|
|
16
|
+
declare bytesRead: number;
|
|
17
|
+
declare path: string | Buffer;
|
|
18
|
+
declare pending: boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export class WriteStream extends Writable implements Node.WriteStream {
|
|
@@ -24,10 +25,10 @@ export class WriteStream extends Writable implements Node.WriteStream {
|
|
|
24
25
|
super.emit('close');
|
|
25
26
|
callback();
|
|
26
27
|
} catch (err) {
|
|
27
|
-
callback(err);
|
|
28
|
+
callback(new ApiError(ErrorCode.EIO, (err as Error).toString()));
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
bytesWritten: number;
|
|
31
|
-
path: string | Buffer;
|
|
32
|
-
pending: boolean;
|
|
31
|
+
declare bytesWritten: number;
|
|
32
|
+
declare path: string | Buffer;
|
|
33
|
+
declare pending: boolean;
|
|
33
34
|
}
|