Create a gist now

Instantly share code, notes, and snippets.

line by line stream readers from npm, a case study

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')


line_tool.on('line', function(line) {
  // do stuff with line
  1. backwards compatibility


  1. performance

how do you benchmark streams?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment