UNPKG

737 BMarkdownView Raw
1#through
2
3[![build status](https://secure.travis-ci.org/dominictarr/through.png)](http://travis-ci.org/dominictarr/through)
4
5Easy 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.
6Use `this.pause()` and `this.resume()` to manage flow.
7Check `this.paused` to see current flow state. (write always returns `!this.paused`)
8
9this function is the basis for most of the syncronous streams in [event-stream](http://github.com/dominictarr/event-stream).
10
11``` js
12var through = require('through')
13
14through(function write(data) {
15 this.emit('data', data)
16 //this.pause()
17 },
18 function end () { //optional
19 this.emit('end')
20 })
21
22```