summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorCalvin Metcalf <calvin.metcalf@gmail.com>2014-05-13 11:52:38 -0400
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-05-21 16:48:46 -0700
commit31150df92a5c5e726a4aa12b78a2589e7b20f1ec (patch)
tree7189f3e4f2aafc5625695aeeaa21fdbe378c6f69 /doc
parent1d90b5b78e40ad5165e2eaec14e8f230bd08658d (diff)
downloadnode-31150df92a5c5e726a4aa12b78a2589e7b20f1ec.tar.gz
doc: clarify `end` vs `finish` in streams
Adds a section to the transform stream docs to clarify the difference between the `end` event and the `finish` events. Also clarifies the wording on the `end` event.
Diffstat (limited to 'doc')
-rw-r--r--doc/api/stream.markdown12
1 files changed, 11 insertions, 1 deletions
diff --git a/doc/api/stream.markdown b/doc/api/stream.markdown
index be3aacfeb..40ee0a38a 100644
--- a/doc/api/stream.markdown
+++ b/doc/api/stream.markdown
@@ -160,7 +160,7 @@ readable.on('data', function(chunk) {
#### Event: 'end'
-This event fires when no more data will be provided.
+This event fires when there will be no more data to read.
Note that the `end` event **will not fire** unless the data is
completely consumed. This can be done by switching into flowing mode,
@@ -1121,6 +1121,14 @@ the class that defines it, and should not be called directly by user
programs. However, you **are** expected to override this method in
your own extension classes.
+#### Events: 'finish' and 'end'
+
+The [`finish`][] and [`end`][] events are from the parent Writable
+and Readable classes respectively. The `finish` event is fired after
+`.end()` is called and all chunks have been processed by `_transform`,
+`end` is fired after all data has been output which is after the callback
+in `_flush` has been called.
+
#### Example: `SimpleProtocol` parser v2
The example above of a simple protocol parser can be implemented
@@ -1464,6 +1472,8 @@ modify them.
[Writable]: #stream_class_stream_writable
[Duplex]: #stream_class_stream_duplex
[Transform]: #stream_class_stream_transform
+[`end`]: #stream_event_end
+[`finish`]: #stream_event_finish
[`_read(size)`]: #stream_readable_read_size_1
[`_read()`]: #stream_readable_read_size_1
[_read]: #stream_readable_read_size_1