{"dist":{"shasum":"01fba39774ecfdbb307c336453c1b7c0844bcc92","tarball":"https://registry.npmjs.org/duplex/-/duplex-0.2.0.tgz"},"name":"duplex","author":{"url":"http://dominictarr.com","name":"Dominic Tarr","email":"dominic.tarr@gmail.com"},"readme":"# duplex\n\n<img src=https://secure.travis-ci.org/dominictarr/duplex.png?branch=master>\n\n\nSimple base class for [duplex](https://github.com/dominictarr/stream-spec#duplex) streams, that automatically handles pausing and buffering.\n\n``` js\n\nvar duplex = require('duplex')\n\nvar d = duplex()\n  .on('write', function (data) {\n    d.sendData(data)\n  })\n  .on('ended', function () {\n    d.sendEnd()\n  })\n```\n\n## API\n\n### on('write', function (data))\n\nEmitted when `write(data)` is called.\n\n### on('ended', function ())\n\nEmitted when `end()` is called\n\n### sendData(data)\n\nAdd `data` to the output buffer. \n`'data'` will be emitted if there the stream is not paused.\n\n### sendEnd()\n\nEmit `'end'` after the output buffer drains.  \nWill be emitted immediately, it the buffer is empty.\n\n### pause()\n\nSet the readable side of the stream into paused state.  \nThis will prevent it from emitting 'data' or or 'end'\nuntil resume is called.\n\n### resume()\nSet the reabable side of the stream into the unpaused state.  \nThis will allow it to emit `'data'` and `'end'` events.  \nIf there there is any data in the output buffer,  \nIt will start draining immediately.  \n\n## Automatic Behaviours\n\n`destroy()` is called automitically after both sides of the stream has ended.\n`write()==false` after the stream emits `'pause'`,  \nand `write()==true` after the stream emits `'drain'`.\nThe user is responsible for emitting `'pause'` and `'drain'`.\n\nThe stream will call `resume()` in the next tick, unless `pause()` is called manually.\nif `resume()` is manually called before the next tick, the stream will start emitting data\nimmediately.\n\n## License\n\nMIT / APACHE 2\n","scripts":{"test":"node test/index.js"},"_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"homepage":"https://github.com/dominictarr/duplex","repository":{"url":"git://github.com/dominictarr/duplex.git","type":"git"},"_npmVersion":"1.1.59","description":"base class for a duplex stream","directories":{},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}],"_id":"duplex@0.2.0","version":"0.2.0"}