fs-zoo
Version:
File system abstractions and implementations
39 lines (38 loc) • 1.6 kB
TypeScript
import type * as crud from '../crud/types';
declare class LayerMatch {
readonly fs: crud.CrudApi;
readonly rest: string;
constructor(fs: crud.CrudApi, rest: string);
}
/**
* An "overlay" file system, which can combine multiple CRUD-fs file systems
* into one. Accepts one default file system and any number of additional
* file systems to overlay on top at specific paths.
*
* A layer mounted at `''` (or `[]`) will be the default file system, it will
* receive all requests that do not match any other layer.
*
* Example:
*
* ```
* const fs = new OverlayCrud();
* fs.overlay([], root);
* fs.overlay(['usr', 'virtual'], userHome);
* ```
*/
export declare class OverlayCrud implements crud.CrudApi {
protected readonly prefix: string[];
protected _layers: Record<string, crud.CrudApi>;
constructor(layers?: Record<string, crud.CrudApi>, prefix?: string[]);
overlay(path: string, fs: crud.CrudApi): void;
protected _match(path: string): LayerMatch;
readonly put: (path: string, data: Uint8Array, options?: crud.CrudPutOptions) => Promise<void>;
readonly getStream: (path: string) => Promise<ReadableStream>;
readonly del: (path: string, silent?: boolean) => Promise<void>;
readonly info: (path: string) => Promise<crud.CrudResourceInfo>;
readonly drop: (path: string, silent?: boolean) => Promise<void>;
readonly scan: (path: string) => AsyncIterableIterator<crud.CrudCollectionEntry>;
readonly list: (path: string) => Promise<crud.CrudCollectionEntry[]>;
readonly from: (path: string) => Promise<crud.CrudApi>;
}
export {};