Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
an evented, line-oriented I/O library for node.js
JavaScript
tag: v0.0.1

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
README.md
package.json

README.md

NAME

lines-adapter - an evented, line-oriented I/O library for node.js

SYNOPSIS

   var lines=require("lines-adapter");

   lines(stream, 'utf8')
    .on(
        'data',
        function(line) {
            // invoked for each line of input
        }
    )
    .end(
        'end',
        function(end) {
            // invoked at the end of stream
        }
    );

DESCRIPTION

Adapts a readable byte stream to produce a stream of lines.

lines(stream,encoding)

The lines-adapter module is a function which constructs a line stream from a byte stream and an optional encoding argument. The supported encodings are those supported by Buffer.toString(). If no encoding is specified, 'utf8' is assumed.

Event: 'data'

The 'data' event emits a string for each line of input in the adapted byte stream. The emitted line does not contain a trailing \n. A single trailing \r will be removed, if present.

Event: 'end'

Emitted when the stream has received an EOF. Indicates that no more 'data' events will happen.

INSTALLATION

npm install lines-adapter

EXAMPLES

Two examples are provided in the examples/ directory: count-lines and copy-lines.

$> echo foobar | node examples/count-lines.js
1

$> echo foobar | node exmaples/copy-lines.js
foobar

SIMILAR PACKAGES

Floby's node-lines package provides similar functionality to this library although it has a different philosophy. In particular node-lines emits 'line' events whereas node-lines-adapter emits 'data' events.

Something went wrong with that request. Please try again.