@zenfs/core 0.5.12 → 0.6.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/backends/backend.d.ts +2 -7
- package/dist/backends/backend.js +1 -34
- package/dist/browser.min.js +4 -4
- package/dist/browser.min.js.map +3 -3
- package/dist/config.d.ts +16 -12
- package/dist/config.js +49 -18
- package/dist/emulation/index.d.ts +1 -1
- package/dist/emulation/index.js +1 -1
- package/dist/emulation/promises.js +7 -7
- package/dist/emulation/shared.d.ts +2 -2
- package/dist/emulation/shared.js +2 -2
- package/dist/emulation/sync.js +6 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +3 -2
|
@@ -73,17 +73,12 @@ export declare function createBackend<B extends Backend>(backend: B, options?: o
|
|
|
73
73
|
*
|
|
74
74
|
* The option object for each file system corresponds to that file system's option object passed to its `Create()` method.
|
|
75
75
|
*/
|
|
76
|
-
export interface
|
|
76
|
+
export interface BackendConfiguration<FS extends FileSystem = FileSystem, OC extends BackendOptionsConfig = BackendOptionsConfig> {
|
|
77
77
|
backend: Backend<FS, OC>;
|
|
78
78
|
[key: string]: unknown;
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* @internal
|
|
82
82
|
*/
|
|
83
|
-
export declare function isBackendConfig(arg: unknown): arg is
|
|
84
|
-
/**
|
|
85
|
-
* Retrieve a file system with the given configuration.
|
|
86
|
-
* @param config A BackendConfig object.
|
|
87
|
-
*/
|
|
88
|
-
export declare function resolveBackend<FS extends FileSystem>(options: BackendConfig<FS>, _depth?: number): Promise<FS>;
|
|
83
|
+
export declare function isBackendConfig(arg: unknown): arg is BackendConfiguration;
|
|
89
84
|
export {};
|
package/dist/backends/backend.js
CHANGED
|
@@ -53,38 +53,5 @@ export function createBackend(backend, options) {
|
|
|
53
53
|
* @internal
|
|
54
54
|
*/
|
|
55
55
|
export function isBackendConfig(arg) {
|
|
56
|
-
return arg != null && typeof arg == 'object' && 'backend' in arg;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Retrieve a file system with the given configuration.
|
|
60
|
-
* @param config A BackendConfig object.
|
|
61
|
-
*/
|
|
62
|
-
export async function resolveBackend(options, _depth = 0) {
|
|
63
|
-
if (typeof options !== 'object' || options == null) {
|
|
64
|
-
throw new ApiError(ErrorCode.EINVAL, 'Invalid options on configuration object.');
|
|
65
|
-
}
|
|
66
|
-
const { backend } = options;
|
|
67
|
-
if (!isBackend(backend)) {
|
|
68
|
-
throw new ApiError(ErrorCode.EINVAL, 'Missing or invalid backend');
|
|
69
|
-
}
|
|
70
|
-
const props = Object.keys(options).filter(k => k != 'backend');
|
|
71
|
-
for (const prop of props) {
|
|
72
|
-
let option = options[prop];
|
|
73
|
-
if (isBackend(option)) {
|
|
74
|
-
option = { backend: option };
|
|
75
|
-
}
|
|
76
|
-
if (isBackendConfig(option)) {
|
|
77
|
-
if (_depth > 10) {
|
|
78
|
-
throw new ApiError(ErrorCode.EINVAL, 'Invalid configuration, too deep and possibly infinite');
|
|
79
|
-
}
|
|
80
|
-
options[prop] = await resolveBackend(option, ++_depth);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (!(await backend.isAvailable())) {
|
|
84
|
-
throw new ApiError(ErrorCode.EPERM, 'Backend not available: ' + backend);
|
|
85
|
-
}
|
|
86
|
-
checkOptions(backend, options);
|
|
87
|
-
const fs = backend.create(options);
|
|
88
|
-
await fs.ready();
|
|
89
|
-
return fs;
|
|
56
|
+
return arg != null && typeof arg == 'object' && 'backend' in arg && isBackend(arg.backend);
|
|
90
57
|
}
|