split-stream

stream of split strings

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
split-stream
000.2.011 years ago11 years agoMinified + gzip package size for split-stream in KB

Readme

split-stream Build Status
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 object

  • return 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.