Skip to content

Latest commit

History

52 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

build status Carrier helps you implement new-line terminated protocols over node.js.

The client can send you chunks of lines and carrier will only notify you on each completed line.

Install

$ npm install carrier

Usage

varnet=require('net'),carrier=require('carrier');varserver=net.createServer(function(conn){carrier.carry(conn,function(line){console.log('got one line: '+line);});});server.listen(4001);

Or, you can also listen to the "line" event on the returned object of carrier.carry() like this:

varnet=require('net'),carrier=require('carrier');varserver=net.createServer(function(conn){varmy_carrier=carrier.carry(conn);my_carrier.on('line',function(line){console.log('got one line: '+line);});});server.listen(4001);

carrier.carry accepts the following options:

carrier.carry(reader,listener,encoding,separator)
  • reader: the stream reader
  • listener: a "line" event listener function
  • encoding: what encoding to assume. Default: "utf8"
  • separator: what line separator to use. Default: /\r?\n/

All are optional except for the first.

About

Evented stream line reader for node.js

Resources

Stars

125 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages