Licence
MIT
Version
0.2.0
Deps
0
Size
117 kB
Vulns
0
Weekly
0
@xfcfam/xf-fs
Filesystem Access Generalization for the XF Architecture Model —
node:fsbehind one coherent, XF-compliantFileRepository.
For React Native,
@xfcfam/xf-reactnative-fsexposes the same API (and re-uses these Transfer types) over the device filesystem instead ofnode:fs.
Install
npm i @xfcfam/xf @xfcfam/xf-fsQuick start
import { FileRepository } from '@xfcfam/xf-fs'
export class UsersFileRepository extends FileRepository {
constructor() { super({ rootPath: '/var/data/users' }) }
async findById(id: string) { return JSON.parse(await this.read(`${id}.json`)) }
async save(u: User) { await this.write(`${u.id}.json`, JSON.stringify(u)) }
}Exported Components
Generalizations
| Component | Description |
|---|---|
FileRepository |
The whole local-filesystem protocol over node:fs. Returns FileStat / FileEntry, hands back Watcher / TempFile handles, and raises typed FileNotFoundException / FileAccessDeniedException / DirectoryNotEmptyException. |
CachedFileRepository |
Adds a write-through in-memory cache over read / readBytes. |
AuditedFileRepository |
Adds an observability policy — every operation fires a hook. |
Utilities
| Component | Description |
|---|---|
PathUtils |
Pure POSIX path manipulation. |
EncodingUtils |
BOM-aware UTF-8 encoding helpers. |
Three filesystem errors become typed exceptions —
FileNotFoundException←ENOENT,FileAccessDeniedException←EACCES/EPERM,DirectoryNotEmptyException←ENOTEMPTY. Anything else propagates as nativeError.
Documentation
Full specification → xfcfam.org
License
MIT