0.2.0 • Published 11 years ago
split-stream v0.2.0
split-stream
stream of split strings
Installation
$ npm install split-stream
Usage
var fs = require('fs'),
splitStream = require('split-stream'),
ss = splitStream.create();
fs.createReadStream('./file').pipe(ss).pipe(process.stdout);
var fs = require('fs'),
splitStream = require('split-stream'),
ss = splitStream.create();
ss.setEncoding('utf8');
ss.on('data', function(data) {
console.log(data);
});
ss.on('end', function() {
ss.destory();
});
ss.on('close', function() {
console.log('close');
});
fs.createReadStream('./file').pipe(ss);
Functions
create(options)
options
object - option objectreturn
SplitStream - SplitStream
throw TypeError if options.splitStr is not string or regexp types.
options
splitStr
string or regexp - split string
default value is /\r?\n/
.
Events
close
called destroy().
data
data
string - split string
drain
when buffer is empty.
end
call after end() and when buffer is empty.
error
error
Error - error object
call twice destory() or call write() after end().
Test
$ npm install
$ npm test
License
The MIT License. Please see LICENSE file.