UNPKG

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