Simple wrapper around
fs.watch that works around the various issues
you have to deal with when using the Node API directly.
More precisely filewatcher …
fs.watchFilewhen running out of file handles
var filewatcher = ;var watcher = ;// watch a filewatcher;// ... or a directorywatcher;watcher;
To stop watching, you can remove either a single file or all watched files at once:
When the process runs out of file handles, filewatcher closes all watchers and transparently switches to
fs.watchFile polling. You can notify your users by listening to the
You can pass options to
filewatcher() in order to tweak its internal settings. These are the defaults:
// the default optionsvar opts =forcePolling: false // try event-based watching firstdebounce: 10 // debounce events in non-polling mode by 10msinterval: 1000 // if we need to poll, do it every 1000mspersistent: true // don't end the process while files are watched;var watcher =
Copyright (c) 2013-2016 Felix Gnass
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.