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

readline

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

readline - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

2

package.json
{
"name": "readline",
"version": "0.0.7",
"version": "0.0.8",
"description": "Simple streaming readline module.",

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

@@ -17,6 +17,7 @@ var fs = require('fs'),

lineCount = 0,
emit = function(line, count) {
self.emit('line', new Buffer(line).toString(), count);
byteCount = 0,
emit = function(line, lineCount, byteCount) {
self.emit('line', new Buffer(line).toString(), lineCount, byteCount);
};
this.input = fs.createReadStream(file);
this.input = fs.createReadStream(file, opts);
this.input.on('open', function(fd) {

@@ -27,5 +28,6 @@ self.emit('open', fd);

for (var i = 0; i < data.length; i++) {
byteCount++;
if (0 <= newlines.indexOf(data[i])) { // Newline char was found.
lineCount++;
if (line.length) emit(line, lineCount);
if (line.length) emit(line, lineCount, byteCount);
line = []; // Empty buffer.

@@ -44,3 +46,3 @@ } else {

lineCount++;
emit(line, lineCount);
emit(line, lineCount, byteCount);
}

@@ -47,0 +49,0 @@ self.emit('end');

@@ -29,3 +29,3 @@ ## _readline_

rl = readline('./somefile.txt');
rl.on('line', function(line) {
rl.on('line', function(line, lineCount, byteCount) {
// do something with the line of text

@@ -32,0 +32,0 @@ })

@@ -0,3 +1,5 @@

var fs = require('fs');
var readLine = require('../readline.js');
var test = require("tap").test;
var readLine = require('../readline.js');
test("test reading lines",function(t){

@@ -63,1 +65,14 @@ console.error("reading large file line by line asserts may take a while");

test("byte count", function(t){
var rl = readLine('./fixtures/nmbr.txt');
var expect = fs.statSync('./fixtures/nmbr.txt').size;
var actual = 0;
rl.on("line", function (line, ln, byteCount){
console.log("byte count",byteCount);
actual=byteCount;
});
rl.on("end", function (){
t.ok(actual === expect,"byte count is correct");
t.end();
});
});
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