JavaScript file system utilities for Node.js and browser. Implementation of in-memory Node.js fs module API and in-memory browser File System API, as well as adapters from fs module to File Sytem API and from File Sytem API to fs module.
npm i memfs- In-memory Node.js
fsAPI - In-memory browser File System (Access) API
fsto File System (Access) API adapter- File System (Access) API to
fsadapter - Directory
snapshotutility printdirectory tree to terminal- Code reference
- Test coverage
All file-watching APIs are implemented on both sides of the fs and File System API divide:
| Feature | Package | Notes |
|---|---|---|
fs.watch β recursive, encoding, signal, throwIfNoEntry, ignore |
@jsonjoy.com/fs-node |
'error'/'close' events, ref()/unref() |
fs.watchFile / fs.unwatchFile |
@jsonjoy.com/fs-node |
polling, bigint, Node's reappearance semantics |
fs.promises.watch async iterator |
@jsonjoy.com/fs-node |
maxQueue, overflow, AbortError on abort |
FileSystemObserver |
@jsonjoy.com/fs-fsa |
deterministic OPFS profile: precise records, real "moved" records, microtask batching |
fs.watch/fs.watchFile over a real FSA directory |
@jsonjoy.com/fs-fsa-to-node |
works over OPFS in Chrome 133+ via the native observer |
FileSystemObserver over any fs |
@jsonjoy.com/fs-node-to-fsa |
best-effort profile: renames stat-classified, no "moved" records |
Intentional divergences from real watchers (the in-memory backend is deterministic, so platform unreliability is not emulated):
- Paths are watched semantically rather than by inode: after delete-and-recreate, memfs reports events for the recreated entry, while a real POSIX watcher keeps watching the dead inode.
- Exactly one event per logical operation β no platform duplicate events.
filenameis nevernull.- The Node-style
FSWatcherdelivers events synchronously inside the mutating operation, whereas real Node defers to the event loop; theFileSystemObserverbatches per microtask, as the spec requires.
- Git in browser, which writes to a real folder
- Git in browser, which writes to OPFS file system
- Git on in-memory file system
fsin browser, creates a.tarfile in real folderfsin browser, synchronous API, writes to real folder
unionfs- creates a union of multiple filesystem volumesfs-monkey- monkey-patches Node'sfsmodule andrequirefunctionlinkfs- redirects filesystem pathsspyfs- spies on filesystem actions
Apache 2.0