UNPKG

@pstdio/opfs-utils

Version:

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

20 lines (19 loc) 1.25 kB
export declare function ensureDirExists(targetDir: string, create: boolean): Promise<void>; export declare function getDirectoryHandle(path?: string): Promise<string>; /** Resolve a subdirectory under the OPFS root. Creates directories when `create` is true. */ export declare function resolveSubdir(subdir: string, create?: boolean): Promise<string>; /** Get (and optionally create) a directory for a path string relative to root. */ export declare function getDirHandle(path: string, create: boolean): Promise<string>; /** Get a file path (optionally creating) relative to root. */ export declare function getFileHandle(path: string, create: boolean): Promise<string>; /** Read a text file or return null if it doesn't exist. */ export declare function readTextFileOptional(path: string): Promise<string | null>; /** Write text file (mkdir -p as needed). */ export declare function writeTextFile(path: string, content: string): Promise<void>; /** Delete a file if present (no-op when missing). */ export declare function safeDelete(path: string): Promise<void>; /** * Strip ANSI/VT100 escape sequences from a string. * Useful to sanitize copy/pasted colored diffs or terminal-styled inputs. */ export declare function stripAnsi(s: string): string;