Socket
Book a DemoInstallSign in
Socket

este-watch

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

este-watch

Fast and reliable files watcher.

0.1.1
latest
Source
npmnpm
Version published
Weekly downloads
10
100%
Maintainers
1
Weekly downloads
 
Created
Source

este-watch Build Status Dependency Status

Fast and reliable Node.js files watcher.

  • It's fast, because it wraps fs.watch which does not use pooling.
  • It's reliable, because it supports only that behavior that works reliable across all OS's.

Why yet another file watcher?

There are zilions Node.js file watchers. No one is perfect. The most feature rich is probably gaze, but it burns CPU because it uses pooling fs.watchFile. This watcher uses only fs.watch so it has limited functionality (can't detect deleted files), but it works. And it's fast even for thousands of files. Read more here and here.

Basic Usage

Create a watcher to watch all files in the directories "foo" and "bar":

function onWatch(file) {
  // Relative path to file that was changed or created
  console.log(file.filepath);

  // File Extension
  console.log(file.extension);
}

var esteWatch = require('este-watch');

var watcher = esteWatch(['foo', 'bar'], onWatch);

// Start the watcher
watcher.start()

Options

A third argument can be passed to the esteWatch function to specify options.

Three options are available:

  • filter: (RegExp) only fire watcher callback for files where the full relative filepath matches this pattern
  • ignoreFiles: (RegExp) prevent watcher callback from firing for files where the full relative filepath matches this pattern
  • ignoreDirectories: (RegExp) prevent watcher from even starting for directories where the full relative directory path matches this pattern
esteWatch(['foo', 'bar'], onWatch, {
  filter: /\.js$/,
  ignoreFiles: /\.min\.js$/,
  ignoreDirectories: /node_modules/,
}).start();

Keywords

files

FAQs

Package last updated on 22 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.