Comparing version 0.2.0 to 0.2.1
@@ -6,3 +6,3 @@ { | ||
"description": "tail a file in node", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"repository": { | ||
@@ -9,0 +9,0 @@ "type": "git", |
64
tail.js
@@ -17,31 +17,33 @@ var Tail, environment, events, fs; | ||
var block, stream; | ||
block = this.queue[0]; | ||
if (block.end > block.start) { | ||
stream = fs.createReadStream(this.filename, { | ||
start: block.start, | ||
end: block.end - 1, | ||
encoding: "utf-8" | ||
}); | ||
stream.on('error', __bind(function(error) { | ||
console.log("Tail error:" + error); | ||
return this.emit('error', error); | ||
}, this)); | ||
stream.on('end', __bind(function() { | ||
this.queue.shift(); | ||
if (this.queue.length >= 1) { | ||
return this.internalDispatcher.emit("next"); | ||
} | ||
}, this)); | ||
return stream.on('data', __bind(function(data) { | ||
var chunk, parts, _i, _len, _results; | ||
this.buffer += data; | ||
parts = this.buffer.split(this.separator); | ||
this.buffer = parts.pop(); | ||
_results = []; | ||
for (_i = 0, _len = parts.length; _i < _len; _i++) { | ||
chunk = parts[_i]; | ||
_results.push(this.emit("line", chunk)); | ||
} | ||
return _results; | ||
}, this)); | ||
if (this.queue.length >= 1) { | ||
block = this.queue[0]; | ||
if (block.end > block.start) { | ||
stream = fs.createReadStream(this.filename, { | ||
start: block.start, | ||
end: block.end - 1, | ||
encoding: "utf-8" | ||
}); | ||
stream.on('error', __bind(function(error) { | ||
console.log("Tail error:" + error); | ||
return this.emit('error', error); | ||
}, this)); | ||
stream.on('end', __bind(function() { | ||
this.queue.shift(); | ||
if (this.queue.length >= 1) { | ||
return this.internalDispatcher.emit("next"); | ||
} | ||
}, this)); | ||
return stream.on('data', __bind(function(data) { | ||
var chunk, parts, _i, _len, _results; | ||
this.buffer += data; | ||
parts = this.buffer.split(this.separator); | ||
this.buffer = parts.pop(); | ||
_results = []; | ||
for (_i = 0, _len = parts.length; _i < _len; _i++) { | ||
chunk = parts[_i]; | ||
_results.push(this.emit("line", chunk)); | ||
} | ||
return _results; | ||
}, this)); | ||
} | ||
} | ||
@@ -71,4 +73,8 @@ }; | ||
} | ||
Tail.prototype.unwatch = function() { | ||
fs.unwatchFile(this.filename); | ||
return this.queue = []; | ||
}; | ||
return Tail; | ||
})(); | ||
exports.Tail = Tail; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3014
77