Skip to content

Commit 9feca05

Browse files
committed
docs: ✏️ add watcher README note
1 parent e47548a commit 9feca05

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,32 @@ npm i memfs
2424
- [Code reference](https://streamich.github.io/memfs/)
2525
- [Test coverage](https://streamich.github.io/memfs/coverage/lcov-report/)
2626

27+
## Watching
28+
29+
All file-watching APIs are implemented on both sides of the `fs` adn File System API divide:
30+
31+
| Feature | Package | Notes |
32+
| -------------------------------------------------------------------------- | -------------------------------------------------------- | --------------------------------------------------------------------------------------- |
33+
| `fs.watch``recursive`, `encoding`, `signal`, `throwIfNoEntry`, `ignore` | [`@jsonjoy.com/fs-node`](packages/fs-node) | `'error'`/`'close'` events, `ref()`/`unref()` |
34+
| `fs.watchFile` / `fs.unwatchFile` | [`@jsonjoy.com/fs-node`](packages/fs-node) | polling, `bigint`, Node's reappearance semantics |
35+
| `fs.promises.watch` async iterator | [`@jsonjoy.com/fs-node`](packages/fs-node) | `maxQueue`, `overflow`, `AbortError` on abort |
36+
| [`FileSystemObserver`][observer] | [`@jsonjoy.com/fs-fsa`](packages/fs-fsa) | deterministic OPFS profile: precise records, real `"moved"` records, microtask batching |
37+
| `fs.watch`/`fs.watchFile` over a real FSA directory | [`@jsonjoy.com/fs-fsa-to-node`](packages/fs-fsa-to-node) | works over OPFS in Chrome 133+ via the native observer |
38+
| `FileSystemObserver` over any `fs` | [`@jsonjoy.com/fs-node-to-fsa`](packages/fs-node-to-fsa) | best-effort profile: renames stat-classified, no `"moved"` records |
39+
40+
Intentional divergences from real watchers (the in-memory backend is deterministic, so platform
41+
unreliability is not emulated):
42+
43+
- Paths are watched semantically rather than by inode: after delete-and-recreate, memfs reports
44+
events for the recreated entry, while a real POSIX watcher keeps watching the dead inode.
45+
- Exactly one event per logical operation — no platform duplicate events.
46+
- `filename` is never `null`.
47+
- The Node-style `FSWatcher` delivers events synchronously inside the mutating operation, whereas
48+
real Node defers to the event loop; the `FileSystemObserver` batches per microtask, as the spec
49+
requires.
50+
51+
[observer]: https://developer.mozilla.org/en-US/docs/Web/API/FileSystemObserver
52+
2753
## Demos
2854

2955
- [Git in browser, which writes to a real folder](demo/git-fsa/README.md)

0 commit comments

Comments
 (0)