stream of split strings
$ npm install split-stream
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').SplitStream2,
ss = splitStream.create();
ss.on('readable', function() {
var buf;
while ((buf = ss.read(1)) !== null) {
console.log(buf);
}
});
ss.on('end', function() {
console.log('end');
});
fs.createReadStream('./index.js').pipe(ss);
var fs = require('fs'),
splitStream = require('split-stream').SplitStream1,
ss = splitStream.create({
splitStr: '\t'
});
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);
class of SplitStream1 or SplitStream2.
var splitStream = require('split-stream');
// true if over version 0.9.
(splitStream === splitStream.SplitStream2);
// true if over version 0.8.
(splitStream === splitStream.SplitStream2);
inherited stream2 class.
-
`` object - options object
-
return
SplitStream2 - SplitStream2
throw TypeError if options.splitStr is not string or regexp types.
objectMode and decodeStrings are always true.
splitStr
string or regexp - split string
default value is /\r?\n/
.
encoding
string - encoding
default value is utf8
. this value is argument of string_decoder.
inherited old-style stream class.
-
options
object - option object -
return
SplitStream1 - SplitStream1
throw TypeError if options.splitStr is not string or regexp types.
splitStr
string or regexp - split string
default value is /\r?\n/
.
called destroy().
data
string - split string
until buffer is empty.
when buffer is empty.
call after end() and when buffer is empty.
error
Error - error object
call twice destory() or call write() after end().
$ npm install
$ npm test
The MIT License. Please see LICENSE file.