About

By TooTallNate, originally posted at https://gist.github.com/1785026
A quick little thingy that takes a Stream instance and makes
it emit 'line' events when a newline is encountered.
Modified by Max Weller to accept custom line feed characters (e.g. \r\n)

Usage

  var emitLines = require('./emitLines');
  emitLines(process.stdin, "\n")
  process.stdin.resume()
  process.stdin.setEncoding('utf8')
  process.stdin.on('line', function (line) {
    console.log(line event:', line)
  })

Code

Kommentare