rschooley / linely

Node.js line parser for text files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Line by line text file parser

Goal

Parse large text files line by line.

The existing modules trying to do this all have issues:

  • missing last line if no final carriage return
  • use time consuming array operations
  • memory leaks

Benchmark

There is a benchmark testbed with larger files that will be added to a separate repo.

Installing

npm install linely

Using

var LineStream  = require('linely').LineStream,
    stream      = new LineStream();

stream.readFile(filePath);

stream.on('line', function (line, number) {
    // each line
});

stream.on('end', function () {
    // done
});

stream.on('error', function (err) {
    // handle error
});

About

Node.js line parser for text files

License:MIT License


Languages

Language:JavaScript 100.0%