carrier
Evented stream line reader for node.js
Last updated 10 years ago by pgte .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install carrier 
SYNC missed versions from official npm registry.

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

var net     = require('net'),
    carrier = require('carrier');

var server = 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:

var net     = require('net'),
    carrier = require('carrier');

var server = net.createServer(function(conn) {
  var my_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.

Current Tags

  • 0.3.0                                ...           latest (10 years ago)

22 Versions

  • 0.3.0                                ...           10 years ago
  • 0.2.1                                ...           11 years ago
  • 0.1.14                                ...           12 years ago
  • 0.1.13                                ...           13 years ago
  • 0.1.12                                ...           13 years ago
  • 0.1.11                                ...           13 years ago
  • 0.2.0                                ...           13 years ago
  • 0.1.10                                ...           13 years ago
  • 0.1.9                                ...           13 years ago
  • 0.1.8                                ...           13 years ago
  • 0.1.7                                ...           14 years ago
  • 0.1.6                                ...           14 years ago
  • 0.1.5                                ...           14 years ago
  • 0.1.4                                ...           14 years ago
  • 0.1.3                                ...           15 years ago
  • 0.1.2                                ...           15 years ago
  • 0.1.1                                ...           15 years ago
  • 0.0.1                                ...           15 years ago
  • 0.0.3                                ...           15 years ago
  • 0.0.4                                ...           15 years ago
  • 0.1.0                                ...           15 years ago
  • 0.0.2                                ...           15 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 7
Last Day 1
Last Week 6
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |