filename<string> | <Buffer> | <URL>
options<string> | <Object>
persistent<boolean> Indicates whether the process should continue to run as long as files are being watched. Default:
recursive<boolean> Indicates whether all subdirectories should be watched, or only the current directory. This applies when a directory is specified, and only on supported platforms (See caveats). Default:
encoding<string> Specifies the character encoding to be used for the filename passed to the listener. Default:
signal<AbortSignal> allows closing the watcher with an AbortSignal.
listener<Function> | <undefined> Default:
- Returns: <fs.FSWatcher>
Watch for changes on
filename is either a file or a
The second argument is optional. If
options is provided as a string, it
options should be passed as an object.
The listener callback gets two arguments
filename is the name of the file
which triggered the event.
On most platforms,
'rename' is emitted whenever a filename appears or
disappears in the directory.
The listener callback is attached to the
'change' event fired by
<fs.FSWatcher>, but it is not the same thing as the
'change' value of
signal is passed, aborting the corresponding AbortController will close
the returned <fs.FSWatcher>.