0.0.4 • Published 11 years ago

stream-splitter-transform v0.0.4

Weekly downloads
3
License
-
Repository
bitbucket
Last release
11 years ago

stream-splitter-transform

A Transform objectMode stream to break a stream along a separator

new StreamSplitter([separator, options])

A new stream.Transform that splits the input stream along separator and emits each split chunk in objectMode.

separator defaults to \n

options is passed along to the Transform constructor. decodeStrings and objectMode are always set to false and true, respectively

Example: Print a script out line-by-line

var StreamSplitter = require('stream-splitter-transform');
var fs = require('fs');

var splitter = new StreamSplitter();
function readSplitter() {
    var line = splitter.read();
    if (line !== null) {
        console.log("Got line: " + line);
        line = splitter.read();
    }
}
splitter.on('readable', readSplitter);

var thisScript = fs.createReadStream(process.argv[1]);
thisScript.pipe(splitter);

readSplitter();
0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago