delimiter-stream
Takes a stream and transforms it into chunks matching the content between delimiters. Useful for analyzing big data sets and file streams on the fly.
Installation
$ npm install delimiter-stream
Usage
Use the stream to split chunks into chunks separated by the delimter either by
using the data
event or by piping the stream into other streams.
The stream constructor accepts these parameters
- delimiter delimiter used to split stream (default is
\n
) - encoding encoding of the stream (default is
utf8
)
data
event
Using the var DelimiterStream = ;var StringDecoder = StringDecoder;var decoder = 'utf8'; var delimiterstream = delimiter: '|'; delimiterstream; delimiterstream;delimiterstream;delimiterstream;delimiterstream;delimiterstream;
This results in
one
two
three
four
five
Piping
var fs = ;var DelimiterStream = ;var StringDecoder = StringDecoder;var decoder = 'utf8'; var linestream = ; var input = fs; linestream; input;
This will print the contents of somefile.txt
line by line.
The test suite also shows examples on how to use the stream.