Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wtchr

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wtchr

Simple file/directory watcher.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
356
decreased by-6.56%
Maintainers
1
Weekly downloads
 
Created
Source

wtchr

Simple file/directory watcher. (Node.js)

API

It's quite simple to create a wtchr for a directory.

wtchr object

wtchr(path, [options]);
path
  • an absolute dircetory path
options:
  • persistent (boolean) default: true
  • interval (integer) default: 500
  • ignore (regexp) default: /(\/\.DS_Store$)/
Example:
var watch = wtchr('/my/watch/base/directory');

wtchr events

Wtchr provides simple event bindings. The event API is quite similar to jQuery events, so most of JS developers are familiar with it.

bind an event

.on(type, [selector], handler(path, curr lstat, prev lstat))

unbind an event

.off(type, [selector], [handler(path, curr lstat, prev lstat)])
type:
  • one of the 3 supported types create / change / delete
selector
  • a minimatch path selector (simply a filter)
handle:
  • a event handler
Example:
var watch = wtchr('/my/watch/base/directory')

watch.on("create", "*.js", function (path, curr, prev) {
  console.log("New file: " + path);
});

watch.off("create");

Chaining:

wtchr('/my/watch/base/directory')
  .on("create", "*.js", function (path, curr, prev) {
    console.log("New file: " + path);
  })
  .on("change", "*.js", function (path, curr, prev) {
    console.log("File changed: " + path);
  })
  .on("delete", "*.js", function (path, curr, prev) {
    console.log("File deleted: " + path);
  })
  .off("create")
  .off("delete");

stop wtchr

Simply destroy the wtchr object with the destroy method.

.destroy()
Example:
var watch = wtchr('/my/watch/base/directory')

watch.destroy();

Keywords

FAQs

Package last updated on 09 Apr 2013

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc