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

linebyline

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linebyline - npm Package Compare versions

Comparing version

to
1.0.1

2

package.json
{
"name": "linebyline",
"version": "1.0.0",
"version": "1.0.1",
"description": "Simple streaming readline module.",

@@ -5,0 +5,0 @@ "main": "readline.js",

var fs = require('fs'),
EventEmitter = require('events').EventEmitter,
util = require('util'),
newlines = [
13, // \r
10 // \n
];
util = require('util');

@@ -27,4 +23,3 @@ var readLine = module.exports = function(file, opts) {

for (var i = 0; i < data.length; i++) {
byteCount++;
if (0 <= newlines.indexOf(data[i])) { // Newline char was found.
if (data[i] == 10 || data[i] == 13) { // Newline char was found.
lineCount++;

@@ -36,2 +31,3 @@ if (line.length) emit(line, lineCount, byteCount);

}
byteCount++;
}

@@ -44,3 +40,3 @@ })

// Emit last line if anything left over since EOF won't trigger it.
if (line.length){
if (line.length) {
lineCount++;

@@ -47,0 +43,0 @@ emit(line, lineCount, byteCount);

@@ -36,5 +36,15 @@ ## _readline_

```
##API
## readfile(readingObject)
### Params:
* **** *readingObject* {file path or stream}
### Return:
* **EventEmitter**
## License
BSD © [Craig Brookes](http://craigbrookes.com/)

@@ -64,3 +64,18 @@ var fs = require('fs');

test("byte count after first line", function(t){
var rl = readLine('./fixtures/nmbr.txt');
var actual = 0;
var expect;
rl.on("line", function (line, ln, byteCount){
if (expect === undefined) {
expect = line.length;
console.log("byte count",byteCount);
actual=byteCount;
t.ok(actual === expect,"byte count is correct");
t.end();
}
});
});
test("byte count", function(t){

@@ -67,0 +82,0 @@ var rl = readLine('./fixtures/nmbr.txt');