lib/nodefs-handler.js
function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
  const handleEvent = (rawEvent, evPath) => {
    listener(path);
    emitRaw(rawEvent, evPath, {watchedPath: path});

    // emit based on events occurring for files from a directory's watcher in
    // case the file's watcher misses it (and rely on throttling to de-dupe)
    if (evPath && path !== evPath) {
      fsWatchBroadcast(
        sysPath.resolve(path, evPath), 'listeners', sysPath.join(path, evPath)
      );
    }
  };
  try {
    return fs.watch(path, options, handleEvent);
  } catch (error) {
    errHandler(error);
  }
}
function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
  const handleEvent = (rawEvent, evPath) => {
    listener(path);
    emitRaw(rawEvent, evPath, {watchedPath: path});

    // emit based on events occurring for files from a directory's watcher in
    // case the file's watcher misses it (and rely on throttling to de-dupe)
    if (evPath && path !== evPath) {
      fsWatchBroadcast(
        sysPath.resolve(path, evPath), 'listeners', sysPath.join(path, evPath)
      );
    }
  };
  try {
    return fs.watch(path, options, handleEvent);
  } catch (error) {
    errHandler(error);
  }
}
function createFsWatchInstance ( path , options , listener , errHandler , emitRaw ) { const handleEvent = ( rawEvent , evPath ) => { listener ( path ) ; emitRaw ( rawEvent , evPath , { watchedPath : path } ) ; // emit based on events occurring for files from a directory's watcher in // case the file's watcher misses it (and rely on throttling to de-dupe) if ( evPath && path !== evPath ) { fsWatchBroadcast ( sysPath . resolve ( path , evPath ) , 'listeners' , sysPath . join ( path , evPath ) ) ; } } ; try { return fs . watch ( path , options , handleEvent ) ; } catch ( error ) { errHandler ( error ) ; } }
Instantiates the fs_watch interface
@param {String} path to be watched
@param {Object} options to be passed to fs_watch
@param {Function} listener main event handler
@param {Function} errHandler emits info about errors
@param {Function} emitRaw emits raw event data
@returns {fs.FSWatcher} new fsevents instance
Instantiates the fs_watch interface