Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "readline", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Simple streaming readline module.", | ||
@@ -5,0 +5,0 @@ "main": "readline.js", |
@@ -16,13 +16,15 @@ var fs = require('fs'), | ||
line = [], | ||
emit = function(line) { | ||
self.emit('line', new Buffer(line).toString()); | ||
lineCount = 0, | ||
emit = function(line, count) { | ||
self.emit('line', new Buffer(line).toString(), count); | ||
}; | ||
fs.createReadStream(file).on('open', function(fd) { | ||
self.emit('open', fd); | ||
}) | ||
this.input = fs.createReadStream(file); | ||
this.input.on('open', function(fd) { | ||
self.emit('open', fd); | ||
}) | ||
.on('data', function(data) { | ||
for (var i = 0; i < data.length; i++) { | ||
if (0 <= newlines.indexOf(data[i])) { // Newline char was found. | ||
if (line.length) emit(line); | ||
lineCount++; | ||
if (line.length) emit(line, lineCount); | ||
line = []; // Empty buffer. | ||
@@ -39,3 +41,3 @@ } else { | ||
// Emit last line if anything left over since EOF won't trigger it. | ||
if (line.length) emit(line); | ||
if (line.length) emit(line, lineCount); | ||
self.emit('end'); | ||
@@ -42,0 +44,0 @@ }) |
@@ -6,4 +6,6 @@ ## _readline_ | ||
## Important. In node 10 there is a core module named readline. Please use linebyline instead, it is the same module just renamed | ||
```sh | ||
npm install readline | ||
npm install linebyline | ||
``` | ||
@@ -17,3 +19,3 @@ | ||
```js | ||
var readline = require('readline'), | ||
var readline = require('linebyline'), | ||
rl = readline('./somefile.txt'); | ||
@@ -20,0 +22,0 @@ rl.on('line', function(line) { |
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
1954817
85
31