Skip to content

introduce a convenient way to create basic custom streams

License

Notifications You must be signed in to change notification settings

greelgorke/stream-build

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stream-build

this package offers you convenience factory methods for simpler creation of custom streams from the 4 base streams.

Build Status

Usage

Core stream module is re-exported. So you can easy replace require('stream') with require('stream-build') and go on. Now you have 4 factory methods which can be used to create custom streams:

// Before
function MyReadable(opts){
  //this and that
}

util.inherit(MyReadable,Readable)

MyReadable.prototype._read = function(size){
  //custom read code
}

var myReadable = new MyReadable()
// after

var myReadable = streamBuild.readable( function(size){
  //custom read code
}, {/* options here are passed to core constructors */})

Install

npm install stream-build

About Performance

the builder provided here do not use constructors or inheritance. This package aims for readability, so if you worry about performance:

  1. Measure
  2. eliminate bottlenecks

Creating a constructor function and using it as in the before-example may give you some bit better performance, since v8 uses such structures for optimization considerations. It's your choice then.

License

MIT (see license file)

About

introduce a convenient way to create basic custom streams

Resources

License

Stars

Watchers

Forks

Packages

No packages published