@zenfs/dom
Backends for DOM APIs. These are only available natively in browsers.
npm install @zenfs/domReference generated from v1.2.14.
Backends
Section titled “Backends”| Backend | Description |
|---|---|
WebAccess |
Uses the File System Access API, including OPFS. |
IndexedDB |
Stores files in an IndexedDB object database. |
WebStorage |
Stores files in a Storage object, like localStorage and sessionStorage. |
XML |
Uses an XMLDocument to store files, which can be appended to the DOM. |
You can use the backends from @zenfs/dom just like the backends from @zenfs/core:
import { configureSingle, fs } from '@zenfs/core';import { WebStorage } from '@zenfs/dom';
await configureSingle({ backend: WebStorage, storage: localStorage });
if (!fs.existsSync('/test.txt')) { fs.writeFileSync('/test.txt', 'This will persist across reloads!');}
const contents = fs.readFileSync('/test.txt', 'utf-8');console.log(contents);See Using ZenFS for mounting several backends at once, and the reference for every option each backend accepts.