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

nork-tail

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nork-tail - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

test_files/test

0

lib/helpers.js

@@ -0,0 +0,0 @@ var fs = require('fs');

34

lib/watcher.js

@@ -10,5 +10,6 @@ var EventEmitter = require('events').EventEmitter,

var options = options || {};
this.delimiter = options.delimiter || '\n';
this.delimiter = options.delimiter || /\r?\n/;
this.dirname = dir;
this.filter = this.parseFilter(options.filter || null);
this.timeouts = new Hash();
}

@@ -76,3 +77,3 @@

Watcher.prototype.handle = function(event, filename){
if(!filename || (this.filter && !filename.match(this.filter))){return;}
if(!filename || (this.filter && filename.match(this.filter))){return;}
this[event](filename);

@@ -85,3 +86,5 @@ }

if(err){return self.emit('error', err);}
data.split(this.delimiter).forEach(function(item){
var split = data.split(self.delimiter)
split.forEach(function(item){
self.emit('data', item, filename);

@@ -103,3 +106,3 @@ });

if(stat && stat.isFile()){
self.fileState.put(filename, stat.size);
self.fileState.put(filename, {position:stat.size, queue:[]});
self.emit('watch', filename);

@@ -115,12 +118,21 @@ }

Watcher.prototype.change = function(filename) {
var self = this;
fs.stat(self.fullPath(filename), function(err, stat){
if (!stat){return;}
clearTimeout(this.timeouts.get(filename));
this.timeouts.put(filename,
setTimeout(function(){
var file = filename;
if(stat.size > self.fileState.get(filename)){
self.tail(filename, self.fileState.get(filename), stat.size);
}
self.fileState.put(filename, stat.size);
});
fs.stat(self.fullPath(file), function(err, stat){
if (!stat){return;}
if(stat.size > self.fileState.get(file).position){
self.tail(filename, self.fileState.get(file.position), stat.size);
}
self.fileState.get(file).position = stat.size;
});
}, 50)
);
}

@@ -127,0 +139,0 @@

{
"name": "nork-tail",
"version": "0.0.2",
"version": "0.0.3",
"description": "File/Directory monitor for Node.js based on fs.watch()",

@@ -10,6 +10,10 @@ "repository": {

"keywords": [
"fs.watch()","tail"
"fs.watch()",
"tail"
],
"main": "lib/watcher.js",
"author": "Mneme <mneme@gmail.com>",
"main": "lib/watcher.js",
"author": {
"name": "Mneme",
"email": "mneme@gmail.com"
},
"devDependencies": {

@@ -19,5 +23,16 @@ "mocha": "*",

},
"dependencies" : {
"dependencies": {
"nork-hash": "~0.0.3"
}
},
"readme": "Work in progress.\r\n\r\nusage:\r\nvar Watcher = require('NorkWatch');\r\nvar path = require('path');\r\n\r\nvar w = Watcher('./tmp/*');\r\n\r\nw\r\n .on('error', function(err){\r\n console.log(err);\r\n })\r\n .on('data', function(data){\r\n console.log(data);\r\n })\r\n .on('unwatch', function(file){\r\n console.log('unwatching: ' + file);\r\n })\r\n .on('watch', function(file){\r\n console.log('watching: ' + file);\r\n })\r\n .start();",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/mneme/norkwatch/issues"
},
"_id": "nork-tail@0.0.2",
"dist": {
"shasum": "5ddd9b236668b8fea144b70b15e69372efb7d1ce"
},
"_from": "nork-tail@~0.0.1",
"_resolved": "https://registry.npmjs.org/nork-tail/-/nork-tail-0.0.2.tgz"
}
Work in progress.
usage:
var Watcher = require('NorkWatch');
var path = require('path');
var Tail = require('nork-tail');
var w = Watcher('./tmp/*');
Takes two arguments. path to a directory and a regexp for filtering file-names.
var w = Tail('./tmp');
w

@@ -10,0 +11,0 @@ .on('error', function(err){

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