Socket
Socket
Sign inDemoInstall

sane

Package Overview
Dependencies
6
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sane

Sane aims to be fast, small, and reliable file system watcher. No bells and whistles, just change events.


Version published
Maintainers
1
Install size
136 kB
Created

Readme

Source

sane

I've been driven to insanity by node filesystem watcher wrappers. Sane aims to be fast, small, and reliable file system watcher.

Install

Requires node >= v0.10.0.

$ npm install sane

API

sane(dir, globs)

Watches a directory and all it's descendant directorys for changes, deletions, and additions on files and directories. Shortcut for new sane.Watcher(files, {globs: globs}).

var watcher = sane('path/to/dir', ['**/*.js, '**/*.css']);
watcher.on('ready', function () { console.log('ready') });
watcher.on('change', function (filepath) { console.log('file changed', filepath); });
watcher.on('add', function (filepath) { console.log('file added', filepath); });
watcher.on('delete', function (filepath) { console.log('file deleted', filepath); });
// close
watcer.close();

sane.Watcher(dir, options)

options:

  • persistent: boolean indicating that the process shouldn't die while we're watching files.
  • glob: a single string glob pattern or an array of them.

For the glob pattern documentation, see minimatch.

sane.Watcher#close

sane.Watcher events

Emits the following events:

All events are passed the file/dir path relative to the root directory

  • ready when the program is ready to detect events in the directory
  • change when a file changes
  • add when a file or directory has been added
  • delete when a file or directory has been deleted

Stops watching.

License

MIT

Keywords

FAQs

Last updated on 26 Feb 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc