From 618e4ecda99f13c781945df6c3b8433dca3bad87 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 26 Jun 2015 07:51:14 -0700 Subject: [PATCH] doc: add a note about readable in flowing mode Original: https://github.com/joyent/node/pull/8682 Slightly modified version of the original PR (#8682) to add appropriate line wrapping and fix a couple of grammar nits. Reviewed-By: James M Snell PR-URL: https://github.com/joyent/node/pull/25591 --- doc/api/stream.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/api/stream.markdown b/doc/api/stream.markdown index 52326304d9eeb6..3c879eac15b9f6 100644 --- a/doc/api/stream.markdown +++ b/doc/api/stream.markdown @@ -164,6 +164,9 @@ readable.on('readable', function() { Once the internal buffer is drained, a `readable` event will fire again when more data is available. +The `readable` event is not emitted in the "flowing" mode with the +sole exception of the last one, on end-of-stream. + #### Event: 'data' * `chunk` {Buffer | String} The chunk of data. @@ -181,6 +184,9 @@ readable.on('data', function(chunk) { console.log('got %d bytes of data', chunk.length); }); ``` +Note that the `readable` event should not be used together with `data` +because the assigning the latter switches the stream into "flowing" mode, +so the `readable` event will not be emitted. #### Event: 'end'