public
Last active

line by line stream readers from npm, a case study

  • Download Gist
gistfile1.md
Markdown

Stream, npm, cli utilities all awesome. But some tools get repeated waaayyy too much. For example, node line-by-line stream utilities are everywhere. But they can't be created equal can they? What's the criteria for this tool? In my mind, a great line by line stream tool should:

  1. follow the node.js stream api as closely as possible
  2. Use the new stream2 api if possible and remain backwards compatible
  3. perform well (there can be a pretty significant performance difference between different parsing methods)
  4. be very well documented and tested

1. interface

looks like the most noteworthy difference between the interfaces of is the use of events. some of these interfaces go like this:

var line_tool = require('line tool')

fs.createReadStream('thing.txt')
  .pipe(line_tool)

line_tool.on('line', function(line) {
  // do stuff with line
})

2. backwards compatibility

........

3. performance

how do you benchmark streams?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.