@synet/patterns
Version:
Robust, battle-tested collection of stable patterns used in Synet packages
48 lines (40 loc) • 1.27 kB
TypeScript
import type { IAsyncFileSystem } from '../filesystem/promises';
import { Unit, type IUnitOptions } from './unit';
/**
* The foundational file interface - everything is a file
* This interface can be extended to create specific file types
* with additional capabilities as needed.
*
*
*/
export interface IUnitSystem<U> {
readFile(path: string): Promise<string>;
writeFile(path: string, props: U): Promise<void>;
deleteFile(path: string): Promise<void>;
exists(path: string): Promise<boolean>;
}
/**
* Interface for file system operations
* Generic over file type to allow for different file implementations
export interface IUnitOptions {
name?: string
[x: string]: unknown
}
export interface IFileUnit {
data: string;
format: string;
}
/**
* Basic file system implementation
* The foundation that everything builds on
*/
export declare class UnitSystem implements IUnitSystem<Unit> {
private filesystem;
private options?;
private name;
constructor(filesystem: IAsyncFileSystem, options?: IUnitOptions | undefined);
readFile(path: string): Promise<string>;
writeFile(path: string, props: Unit): Promise<void>;
deleteFile(path: string): Promise<void>;
exists(path: string): Promise<boolean>;
}