1 | #through
|
2 |
|
3 | Easy way to create a `Stream` that is both `readable` and `writable`. Pass in optional `write` and `end` methods. `through` takes care of pause/resume logic.
|
4 | Use `this.pause()` and `this.resume()` to manage flow.
|
5 | Check `this.paused` to see current flow state. (write always returns `!this.paused`)
|
6 |
|
7 | this function is the basis for most of the syncronous streams in [event-stream](http://github.com/dominictarr/event-stream).
|
8 |
|
9 | ``` js
|
10 | var through = require('through')
|
11 |
|
12 | through(function write(data) {
|
13 | this.emit('data', data)
|
14 | //this.pause()
|
15 | },
|
16 | function end () { //optional
|
17 | this.emit('end')
|
18 | })
|
19 |
|
20 | ```
|