Permalink
Browse files

update README for new API

  • Loading branch information...
1 parent 56f8dc1 commit 4272f189ee8d0cc0f5b25ec98f8ea7a29eb9c4f0 @dominictarr committed Sep 26, 2012
Showing with 25 additions and 14 deletions.
  1. +25 −14 README.markdown
View
@@ -10,55 +10,66 @@ Simple base class for [duplex](https://github.com/dominictarr/stream-spec#duplex
var duplex = require('duplex')
var d = duplex()
- .on('write', function (data) {
+ .on('_data', function (data) {
d.sendData(data)
})
- .on('ended', function () {
+ .on('_end', function () {
d.sendEnd()
})
```
## API
-### on('write', function (data))
+### on('_data', function (data))
Emitted when `write(data)` is called.
-### on('ended', function ())
+### on('_end', function ())
Emitted when `end()` is called
-### sendData(data)
+### _data(data)
Add `data` to the output buffer.
-`'data'` will be emitted if there the stream is not paused.
+`'data'` will be emitted if the stream is not paused.
-### sendEnd()
+### _end()
-Emit `'end'` after the output buffer drains.
-Will be emitted immediately, it the buffer is empty.
+Cap the output buffer. no more data events may be added.
+`'end'` will be emitted after the buffer drains,
+or immediately, if the stream is unpaused.
### pause()
-Set the readable side of the stream into paused state.
+Pause the readable side of the stream.
This will prevent it from emitting 'data' or or 'end'
until resume is called.
### resume()
-Set the reabable side of the stream into the unpaused state.
+Unpause the readable side of the stream.
This will allow it to emit `'data'` and `'end'` events.
If there there is any data in the output buffer,
It will start draining immediately.
+## _pause(), emit('pause')
+
+Pause the writable side of the stream. this will cause write() to return false,
+so any streams piping into this stream will pause after thier next write.
+
+## emit('drain')
+
+Unpause the writable side of the stream. This will cause `Stream#pipe` to call `resume()`
+on any streams piping to this stream.
+
## Automatic Behaviours
-`destroy()` is called automitically after both sides of the stream has ended.
+`destroy()` is called automatically after both sides of the stream have ended.
`write()==false` after the stream emits `'pause'`,
and `write()==true` after the stream emits `'drain'`.
The user is responsible for emitting `'pause'` and `'drain'`.
-The stream will call `resume()` in the next tick, unless `pause()` is called manually.
-if `resume()` is manually called before the next tick, the stream will start emitting data
+`resume()` will be called on `nextTick`, unless `pause()` was called manually.
+If `resume()` is manually called before the `nextTick`, the stream will start emitting data
immediately.
## License

0 comments on commit 4272f18

Please sign in to comment.