No description, website, or topics provided.
Switch branches/tags
Nothing to show
Latest commit 1bf319f Nov 13, 2012 @dominictarr 1.0.0
Failed to load latest commit information.
test fix test for pauses Oct 20, 2012
.travis.yml travis Aug 26, 2012
LICENSE.APACHE2 initial Jul 25, 2012
LICENSE.MIT initial Jul 25, 2012
README.markdown update README for new API Sep 26, 2012
index.js remove legacy stuff Nov 13, 2012
package.json 1.0.0 Nov 13, 2012



<img src=>

Simple base class for duplex streams, that automatically handles pausing and buffering.

var duplex = require('duplex')

var d = duplex()
  .on('_data', function (data) {
  .on('_end', function () {


on('_data', function (data))

Emitted when write(data) is called.

on('_end', function ())

Emitted when end() is called


Add data to the output buffer. 'data' will be emitted if the stream is not paused.


Cap the output buffer. no more data events may be added. 'end' will be emitted after the buffer drains, or immediately, if the stream is unpaused.


Pause the readable side of the stream.
This will prevent it from emitting 'data' or or 'end' until resume is called.


Unpause the readable side of the stream.
This will allow it to emit 'data' and 'end' events.
If there there is any data in the output buffer,
It will start draining immediately.

_pause(), emit('pause')

Pause the writable side of the stream. this will cause write() to return false, so any streams piping into this stream will pause after thier next write.


Unpause the writable side of the stream. This will cause Stream#pipe to call resume() on any streams piping to this stream.

Automatic Behaviours

destroy() is called automatically after both sides of the stream have ended. write()==false after the stream emits 'pause',
and write()==true after the stream emits 'drain'. The user is responsible for emitting 'pause' and 'drain'.

resume() will be called on nextTick, unless pause() was called manually. If resume() is manually called before the nextTick, the stream will start emitting data immediately.