1.0.4 • Published 7 years ago

quickline v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

byline

Fast line by line parsing of files in node.js. Over 3x the speed of byline module.

Installation

npm install quickline --save

Usage

byLine = require('quickline').byLine



var linecount = 0;

function process_line(x) {
    if(x[0] != "#") linecount ++;
}


function end() {
    console.log("Total lines:" + linecount);
}


var fs = require('fs')

var str = fs.createReadStream( '/etc/passwd', {encoding:'ascii'} )

byLine(str, process_line, end)

Speed

byLine module speed:

time nodejs tests/test-byline.js
1022112

real    0m0.782s
user    0m0.760s
sys     0m0.060s

quickline module speed:

time nodejs tests/test1.js
1022112

real    0m0.221s
user    0m0.220s
sys     0m0.020s

UTF-8 input files

If your input file is encoded as UTF-8, you can use the following alternative function (which can be about 10% slower):

byLineUTF8 = require('..').byLineUTF8

API reference

function byLine(stream, fline, fend);
function byLineUTF8(stream, fline, fend);

License

MIT

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago