@pagepocket/uni-fs
v0.14.5
Published
Unified filesystem helpers for Node and OPFS environments.
Readme
@pagepocket/uni-fs
Unified filesystem helpers that work in Node and OPFS (Origin Private File System).
Install
pnpm add @pagepocket/uni-fsAPI
import {
write,
readAsURL,
readText,
readBinary,
exists,
delete as deleteFile
} from "@pagepocket/uni-fs";
await write("snapshots/page", "html", "<html>...</html>");
const url = await readAsURL("snapshots/page", "html");
const text = await readText("snapshots/page", "html");
const bytes = await readBinary("snapshots/page", "html");
const ok = await exists("snapshots/page", "html");
await deleteFile("snapshots/page", "html");Behavior
- In browsers/Service Workers with OPFS,
readAsURLreturns adata:URL. - In Node,
readAsURLreturns a file path beginning with/.
