@403name/fsevent
v1.0.2
Published
Native filesystem event watcher for Node.js — lightweight FSEvents wrapper with fallback polling
Maintainers
Readme
fsevent
Cross-platform filesystem event watcher for Node.js with recursive support.
Why fsevent?
Native fs.watch wrapper with:
- Recursive directory watching
- Event debouncing (auto-mitigates duplicate events)
- Path filtering
- Zero dependencies
Installation
npm install fseventUsage
const { watch } = require('fsevent');
// Watch directory
const watcher = watch('/path/to/dir', { recursive: true }, (event) => {
console.log('File changed:', event.file, 'Type:', event.type);
});
// Later: stop watching
watcher.close();API
watch(rootDir, options?, callback?): FSEvent
Create a new filesystem watcher.
Options:
recursive(boolean) — Watch subdirectories (default: false)
Events:
change—{ type: 'rename' | 'change', file: string, timestamp: number }error— Error objectready— Watcher is initialized
FSEvent.close()
Stop watching and clean up resources.
License
MIT
