fsevents
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
FSEvents is a package that provides native access to MacOS FSEvents in Node.js. FSEvents API in MacOS allows applications to register for notifications of changes to a directory tree. This makes it a very fast and efficient alternative to kqueue. Its primary function is to track and notify about changes in the file system, making it essential for applications that require real-time updates on such changes. Although it's a low-level library, it's utilized by higher-level, cross-platform file watching modules, such as Chokidar.
To use FSEvents, first, install the package using npm with the command npm install fsevents
. Note that it supports Node.js v8.16 and above. Sample code to use the FSEvents package is as follows:
const fsevents = require('fsevents');
// To start observation
const stop = fsevents.watch(__dirname, (path, flags, id) => {
const info = fsevents.getInfo(path, flags);
});
// To end observation
stop();
In the above code, we require the FSEvents package and start watching a directory. Whenever the operating system detects a change in the file system, the callback function passed to the watch
method is called. The stop
function retrieved and stored is used to end the observation. Make sure to store this stop
function, or the garbage collector might unregister the watcher, eventually causing your callbacks to stop being called.
The FSEvents documentation can be found within its GitHub repository. Here, you can access all the necessary resources, including usage instructions, a detailed breakdown of the API and its features, release notes, and troubleshooting tips. In addition to this, the NPM package page also provides detailed information about the package and its versions.