New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wt

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wt - npm Package Compare versions

Comparing version 0.2.1 to 1.0.0

5

History.md
1.0.0 / 2015-05-07
==================
* improve: do not pass dirs when instantiation
0.2.1 / 2014-11-11

@@ -3,0 +8,0 @@ ==================

61

index.js
/**!
* wt - index.js
*
* Copyright(c) fengmk2 and other contributors.
* Copyright(c) node-modules and other contributors.
* MIT Licensed
*
* Authors:
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
*/

@@ -34,3 +34,3 @@

*/
function Watcher(dirs, options, done) {
function Watcher(options) {
// http://nodejs.org/dist/v0.11.12/docs/api/fs.html#fs_caveats

@@ -41,8 +41,2 @@ // The recursive option is currently supported on OS X.

if (typeof options === 'function') {
// Watcher(dirs, done);
done = options;
options = null;
}
options = options || {};

@@ -59,23 +53,27 @@ if (options.ignoreHidden === undefined || options.ignoreHidden === null) {

if (typeof dirs === 'string') {
dirs = [dirs];
this._watchers = {};
}
Watcher.watch = function (dirs, options, done) {
// watch(dirs, done);
if (typeof options === 'function') {
done = options;
options = null;
}
this._watchers = {};
dirs.forEach(this.watch.bind(this));
// watch(dirs);
if (!done) {
done = function() {};
}
var index = 0;
var that = this;
dirs.forEach(function (dir) {
that.once('watch-' + dir, function () {
if (++index === dirs.length) {
debug('watch %j ready', dirs);
done && done();
var count = Array.isArray(dirs) ? dirs.length : 1;
return new Watcher(options)
.watch(dirs)
.once('error', done)
.on('watch', function () {
count--;
if (count === 0) {
done();
}
});
});
}
Watcher.watch = function (dirs, options, done) {
return new Watcher(dirs, options, done);
};

@@ -88,2 +86,7 @@

proto.watch = function (dir) {
if (Array.isArray(dir)) {
dir.forEach(this.watch.bind(this));
return this;
}
var watchers = this._watchers;

@@ -112,7 +115,10 @@ var that = this;

}).on('error', function (err) {
that.emit('watch-error-' + dir, err);
err.dir = dir;
that.emit('watch-error', err);
}).on('end', function () {
debug('watch %s done', dir);
that.emit('watch-' + dir);
debug('now watching %s', Object.keys(that._watchers));
that.emit('watch', dir);
});
return this;
};

@@ -180,3 +186,2 @@

}
that.emit('all', info);

@@ -183,0 +188,0 @@ if (info.remove) {

{
"name": "wt",
"version": "0.2.1",
"version": "1.0.0",
"description": "wt: Simple dir watcher, including all subdirectories, support multi dirs",

@@ -22,3 +22,2 @@ "main": "index.js",

"contributors": "*",
"cov": "*",
"istanbul": "*",

@@ -25,0 +24,0 @@ "jshint": "*",

@@ -27,4 +27,2 @@ wt

![logo](https://raw.github.com/node-modules/wt/master/logo.png)
wt: Simple dir watcher, including all subdirectories, support events and multi dirs:

@@ -66,2 +64,3 @@

Copyright (c) 2014 fengmk2 <fengmk2@gmail.com> and other contributors
Copyright (c) 2015 node-modules and other contributors

@@ -68,0 +67,0 @@ Permission is hereby granted, free of charge, to any person obtaining

Sorry, the diff of this file is not supported yet

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