You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Michael Winter 555e2c196e initial commit 5 years ago
..
index.js initial commit 5 years ago
license initial commit 5 years ago
package.json initial commit 5 years ago
readme.md initial commit 5 years ago
tracker.js initial commit 5 years ago

readme.md

last-line-stream

A PassThrough stream that keeps track of last line written.

Build Status Coverage Status

Install

$ npm install --save last-line-stream

Usage

const lastLineStream = require('last-line-stream');

const stream = lastLineStream();

stream.write('foo');

assert(stream.lastLine === 'foo');

stream.write('bar');

assert(stream.lastLine === 'foobar');

stream.write('baz\nquz');

assert(stream.lastLine === 'quz');

API

lastLineStream([pipeTo])

Returns a new instance of the spying PassThrough stream,

pipeTo

Type: stream

If supplied, the new instance will automatically be piped to this stream.

stream.lastLine

Type: string

The last line written out to this stream. The lastLine value will grow until the stream sees a newline character ('\n').

Low Level API

A low-level non-stream based API is available. It has only two methods.

var createTracker = require('last-line-stream/tracker');
var tracker = createTracker();

// append some text.
tracker.update(someString);

// Find the complete last line of all the text appended.
tracker.lastLine();

License

MIT © James Talmage