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

tail

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tail - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

README.md

2

package.json

@@ -6,3 +6,3 @@ {

"description": "tail a file in node",
"version": "0.3.0",
"version": "0.3.1",
"repository": {

@@ -9,0 +9,0 @@ "type": "git",

@@ -42,2 +42,5 @@ // Generated by CoffeeScript 1.6.2

_this.buffer += data;
if (_this.pos !== null) {
_this.pos += data.length;
}
parts = _this.buffer.split(_this.separator);

@@ -67,2 +70,8 @@ _this.buffer = parts.pop();

this.isWatching = false;
fs.stat(this.filename, function(err, stats) {
if (err) {
_this.emit('error', err);
}
return _this.pos = stats.size;
});
this.internalDispatcher.on('next', function() {

@@ -74,8 +83,2 @@ return _this.readBlock();

Tail.prototype.unwatch = function() {
fs.unwatchFile(this.filename);
this.isWatching = false;
return this.queue = [];
};
Tail.prototype.watch = function() {

@@ -88,15 +91,62 @@ var _this = this;

this.isWatching = true;
return fs.watchFile(this.filename, this.fsWatchOptions, function(curr, prev) {
if (curr.size > prev.size) {
_this.queue.push({
start: prev.size,
end: curr.size
});
if (_this.queue.length === 1) {
return _this.internalDispatcher.emit("next");
if (fs.watch) {
return this.watcher = fs.watch(this.filename, this.fsWatchOptions, function(e) {
return _this.watchEvent(e);
});
} else {
return fs.watchFile(this.filename, this.fsWatchOptions, function(curr, prev) {
return _this.watchFileEvent(curr, prev);
});
}
};
Tail.prototype.watchEvent = function(e) {
var _this = this;
if (e === 'change') {
return fs.stat(this.filename, function(err, stats) {
if (err) {
_this.emit('error', err);
}
if (stats.size > _this.pos) {
_this.queue.push({
start: _this.pos,
end: stats.size
});
if (_this.queue.length === 1) {
return _this.internalDispatcher.emit("next");
}
}
});
} else if (e === 'rename') {
this.unwatch();
return setTimeout((function() {
return _this.watch();
}), 1000);
}
};
Tail.prototype.watchFileEvent = function(curr, prev) {
if (curr.size > prev.size) {
this.queue.push({
start: prev.size,
end: curr.size
});
if (this.queue.length === 1) {
return this.internalDispatcher.emit("next");
}
});
}
};
Tail.prototype.unwatch = function() {
if (fs.watch) {
this.watcher.close();
this.pos = 0;
} else {
fs.unwatchFile(this.filename);
}
this.isWatching = false;
return this.queue = [];
};
return Tail;

@@ -103,0 +153,0 @@

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