line-iterator

Iterate over streams (actually iterators) by line.

npm install line-iterator
2 downloads in the last week
8 downloads in the last month

line-iterator

Iterate over streams (actually iterators) by line.

To iterate over lines of a stream you need to wrap it in an iterator using stream-iterator.

var createLineIterator = require('line-iterator')
var createStreamIterator = require('stream-iterator')

var fileStream = fs.createReadStream('your_file.txt', {encoding: 'utf8'})

// wrap the file stream in an iterator
var fileIterator = createStreamIterator(fileStream)

// transform the file iterator into a line iterator
var lineIterator = createLineIterator(fileIterator)

// call next() repeatedly to iterate over lines
lineIterator.next(function(err, line) {
  // first line
})

Contributors

npm loves you