Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

quickline

fast line by line parsing of files in node.js Edit

line, csv, tsv, text, byline

readme

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