@push.rocks/smartfile
Version:
High-level file representation classes (SmartFile, StreamFile, VirtualDirectory) for efficient in-memory file management in Node.js using TypeScript. Works seamlessly with @push.rocks/smartfs for filesystem operations.
40 lines (39 loc) • 1.92 kB
TypeScript
import { SmartFile } from './classes.smartfile.js';
import * as plugins from './plugins.js';
export interface IVirtualDirectoryConstructorOptions {
mode: '';
}
/**
* a virtual directory exposes a fs api
* Use SmartFileFactory to create instances of this class
*/
export declare class VirtualDirectory {
static fromFsDirPath(pathArg: string, smartFs?: any, factory?: any): Promise<VirtualDirectory>;
static fromVirtualDirTransferableObject(virtualDirTransferableObjectArg: plugins.smartfileInterfaces.VirtualDirTransferableObject, smartFs?: any, factory?: any): Promise<VirtualDirectory>;
static fromFileArray(files: SmartFile[], smartFs?: any, factory?: any): VirtualDirectory;
static empty(smartFs?: any, factory?: any): VirtualDirectory;
smartfileArray: SmartFile[];
private smartFs?;
private factory?;
constructor(smartFs?: any, factory?: any);
addSmartfiles(smartfileArrayArg: SmartFile[]): void;
addSmartfile(smartfileArg: SmartFile): void;
removeByPath(pathArg: string): boolean;
clear(): void;
merge(otherVDir: VirtualDirectory): void;
exists(pathArg: string): boolean;
has(pathArg: string): boolean;
getFileByPath(pathArg: string): Promise<SmartFile | undefined>;
listFiles(): SmartFile[];
listDirectories(): string[];
filter(predicate: (file: SmartFile) => boolean): VirtualDirectory;
map(fn: (file: SmartFile) => SmartFile): VirtualDirectory;
find(predicate: (file: SmartFile) => boolean): SmartFile | undefined;
size(): number;
isEmpty(): boolean;
toVirtualDirTransferableObject(): Promise<plugins.smartfileInterfaces.VirtualDirTransferableObject>;
saveToDisk(dirArg: string): Promise<void>;
shiftToSubdirectory(subDir: string): Promise<VirtualDirectory>;
loadFromDisk(dirArg: string): Promise<void>;
addVirtualDirectory(virtualDir: VirtualDirectory, newRoot: string): Promise<void>;
}