UNPKG

@pstdio/opfs-utils

Version:

Utilities for the browser's OPFS: ls, grep, safe file read, unified diff patching, and MIME helpers.

36 lines (35 loc) 1.21 kB
declare class MemFileHandle { kind: "file"; name: string; private content; constructor(name: string, content?: string); getFile(): Promise<File>; createWritable(opts?: { keepExistingData?: boolean; }): Promise<{ write(data: unknown): Promise<void>; seek(position: number): Promise<void>; close(): Promise<void>; }>; } declare class MemDirHandle { kind: "directory"; name: string; private children; constructor(name: string); entries(): AsyncGenerator<(string | MemFileHandle | MemDirHandle)[], void, unknown>; keys(): AsyncGenerator<string, void, unknown>; getDirectoryHandle(name: string, opts?: { create?: boolean; }): Promise<MemDirHandle>; getFileHandle(name: string, opts?: { create?: boolean; }): Promise<MemFileHandle>; removeEntry(name: string): Promise<void>; } export declare function setupTestOPFS(): MemDirHandle; export declare function writeFile(root: any, path: string, content: string): Promise<void>; export type TestDirHandle = MemDirHandle; export type TestFileHandle = MemFileHandle; export declare function getOPFSRoot(): Promise<FileSystemDirectoryHandle>; export {};