0.2.0 • Published 11 years ago

split-stream v0.2.0

Weekly downloads
484
License
-
Repository
github
Last release
11 years ago

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.

0.2.0

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago