ProtectedchildrenDirect children of watchedDirectory, kept in sync to classify changes and to diff a rescan.
Protected ReadonlyclientProtected ReadonlyhostReadonlyonFires when directory changes, for example when a missing target appears as a file.
Protected ReadonlyrouterWho asked, and what they excluded.
Protected ReadonlytargetPath this watcher was asked about; the subclass decides what it resolves to.
Protected ReadonlytimingsProtectedwatchedWhat is being watched, and what changes are resolved against.
ProtectedwatchThe path polled and resolved on each start: the target, or its directory once it turned out to be a file.
ReadonlywhenResolves once this watcher disposed itself. Never rejects.
ReadonlywhenResolves once the watcher is up, or once it got disposed while starting. Never rejects.
The directory the handle is on, settled once whenStarted resolved.
A disposed watcher released its resources and must not be given further requests.
Serves request until removeRequest is called with the same watcherId.
Serves requests that a re-key moved here. After the work queued before them runs, each hears where its path differs from what it takes it for.
ProtectedconfirmThe child's name on disk, which can differ from fileName in case, or undefined if there is none.
ProtectedconfirmConfirms the deletions of scheduled still waiting on timer. A deletion cancelled meanwhile is no longer on
it. Only the names this timer scheduled are checked, so each confirmation costs its own batch, not every pending one.
ProtectedcreateA new EventBatch. Where names ignore case, its lookups share one directory read.
ProtectedcreateProtecteddebugProtecteddiffDeletions come first, so a case-only rename resolves to an update for a request for the file.
ProtectederrorLogs as-is. Unlike info it is not prefixed, since these messages name their own path.
ProtectedhandleProtectedinfoProtectedisCompares identity rather than mere existence: a directory that is deleted and recreated leaves the handle bound to the old inode, where it would never report anything again.
ProtectedmarkMarks this watcher disposed.
false if it already was, in which case the caller must not clean up again.
Protectednamestrue if an event names the watched directory itself rather than a child. macOS reports such an
event for any change inside, so isWatchedDirectoryGone decides whether the directory is gone. A
new child with the same name is not in children yet, so the disk rules it out.
ProtectedopenProtectedopenPolls until the target exists as a directory to watch and a handle is open.
ProtectedprocessReleases a request. The watcher disposes itself once it has none left.
ProtectedresolveThe change this rename resolves to, or undefined when it is deferred to the delete timer.
ProtectedresolveResolves the target to the directory to watch. Requests made while the target was missing are resolved here too, and narrowed to the file if the target is one.
false if the path is a file that the watcher cannot follow to its parent.
ProtectedrestartCloses the handle and starts over, reporting the watched paths as deleted if the directory is gone.
Optionalerror: unknownProtectedstartWaits for the target, then opens the handle before reading the children, so no change is missed.
Drains the requests, so that they can be moved to the watcher serving their directory.
Watches one directory level with Node's
fs.watch.One instance serves every non-recursive request resolving to the same directory, for the directory itself or for a single file in it. Sharing saves more than handles: on macOS libuv keeps one
FSEventStreamper event loop and rebuilds it whenever a handle opens or closes, losing every other watcher's events.