fs-zoo
Version:
File system abstractions and implementations
44 lines (43 loc) • 1.89 kB
TypeScript
import type * as crud from '../crud/types';
declare abstract class MemoryNode {
parent: MemoryCollection | undefined;
name: string;
constructor(parent: MemoryCollection | undefined, name: string);
path(): string;
}
declare class MemoryResource extends MemoryNode {
data: Uint8Array;
created: number;
modified: number;
readable: boolean;
writable: boolean;
}
declare class MemoryCollection extends MemoryNode {
parent: MemoryCollection | undefined;
name: string;
children: Map<string, MemoryCollection | MemoryResource>;
created: number;
modified: number;
readable: boolean;
writable: boolean;
constructor(parent?: MemoryCollection | undefined, name?: string);
add(id: string): MemoryResource;
}
export declare class MemoryCrud implements crud.CrudApi {
protected readonly root: MemoryCollection;
constructor(root?: MemoryCollection);
protected _dir(collection: string[], create: boolean): Promise<[dir: MemoryCollection, parent: MemoryCollection | undefined]>;
protected _file(collection: string[], id: string): Promise<[dir: MemoryCollection, file: MemoryResource]>;
write(path: string, options?: crud.CrudPutOptions): Promise<WritableStream>;
dir(path: string, options?: Pick<crud.CrudPutOptions, 'throwIf'>): Promise<void>;
put(path: string, data: Uint8Array, options?: crud.CrudPutOptions): Promise<void>;
_get(collection: string[], id: string): Promise<MemoryResource>;
read(path: string): Promise<ReadableStream>;
del(path: string, silent?: boolean): Promise<void>;
info(path: string): Promise<crud.CrudResourceInfo>;
drop(path: string, silent?: boolean): Promise<void>;
scan(path: string): AsyncIterableIterator<crud.CrudCollectionEntry>;
list(path: string): Promise<crud.CrudCollectionEntry[]>;
from(path: string): Promise<crud.CrudApi>;
}
export {};