3 [![build status](https://secure.travis-ci.org/dominictarr/through.png)](http://travis-ci.org/dominictarr/through)
4 [![testling badge](https://ci.testling.com/dominictarr/through.png)](https://ci.testling.com/dominictarr/through)
6 Easy way to create a `Stream` that is both `readable` and `writable`.
8 * Pass in optional `write` and `end` methods.
9 * `through` takes care of pause/resume logic if you use `this.queue(data)` instead of `this.emit('data', data)`.
10 * Use `this.pause()` and `this.resume()` to manage flow.
11 * Check `this.paused` to see current flow state. (`write` always returns `!this.paused`).
13 This function is the basis for most of the synchronous streams in
14 [event-stream](http://github.com/dominictarr/event-stream).
17 var through = require('through')
19 through(function write(data) {
20 this.queue(data) //data *must* not be null
22 function end () { //optional
27 Or, can also be used _without_ buffering on pause, use `this.emit('data', data)`,
31 var through = require('through')
33 through(function write(data) {
34 this.emit('data', data)
37 function end () { //optional
44 You will probably not need these 99% of the time.
48 By default, `through` emits close when the writable
49 and readable side of the stream has ended.
50 If that is not desired, set `autoDestroy=false`.
53 var through = require('through')
56 var ts = through(write, end, {autoDestroy: false})
58 var ts = through(write, end)
59 ts.autoDestroy = false