@@ -962,8 +962,9 @@ changes:
962962-->
963963
964964The ` 'readable' ` event is emitted when there is data available to be read from
965- the stream. In some cases, attaching a listener for the ` 'readable' ` event will
966- cause some amount of data to be read into an internal buffer.
965+ the stream or when the end of the stream has been reached. Effectively, the
966+ ` 'readable' ` event indicates that the stream has new information. If data is
967+ available, [ ` stream.read() ` ] [ stream-read ] will return that data.
967968
968969``` js
969970const readable = getReadableStreamSomehow ();
@@ -977,14 +978,10 @@ readable.on('readable', function() {
977978});
978979```
979980
980- The ` 'readable' ` event will also be emitted once the end of the stream data
981- has been reached but before the ` 'end' ` event is emitted.
982-
983- Effectively, the ` 'readable' ` event indicates that the stream has new
984- information: either new data is available or the end of the stream has been
985- reached. In the former case, [ ` stream.read() ` ] [ stream-read ] will return the
986- available data. In the latter case, [ ` stream.read() ` ] [ stream-read ] will return
987- ` null ` . For instance, in the following example, ` foo.txt ` is an empty file:
981+ If the end of the stream has been reached, calling
982+ [ ` stream.read() ` ] [ stream-read ] will return ` null ` and trigger the ` 'end' `
983+ event. This is also true if there never was any data to be read. For instance,
984+ in the following example, ` foo.txt ` is an empty file:
988985
989986``` js
990987const fs = require (' fs' );
@@ -1005,6 +1002,9 @@ readable: null
10051002end
10061003```
10071004
1005+ In some cases, attaching a listener for the ` 'readable' ` event will cause some
1006+ amount of data to be read into an internal buffer.
1007+
10081008In general, the ` readable.pipe() ` and ` 'data' ` event mechanisms are easier to
10091009understand than the ` 'readable' ` event. However, handling ` 'readable' ` might
10101010result in increased throughput.
0 commit comments