@@ -960,8 +960,9 @@ changes:
960960-->
961961
962962The ` 'readable' ` event is emitted when there is data available to be read from
963- the stream. In some cases, attaching a listener for the ` 'readable' ` event will
964- cause some amount of data to be read into an internal buffer.
963+ the stream or when the end of the stream has been reached. Effectively, the
964+ ` 'readable' ` event indicates that the stream has new information. If data is
965+ available, [ ` stream.read() ` ] [ stream-read ] will return that data.
965966
966967``` js
967968const readable = getReadableStreamSomehow ();
@@ -975,14 +976,10 @@ readable.on('readable', function() {
975976});
976977```
977978
978- The ` 'readable' ` event will also be emitted once the end of the stream data
979- has been reached but before the ` 'end' ` event is emitted.
980-
981- Effectively, the ` 'readable' ` event indicates that the stream has new
982- information: either new data is available or the end of the stream has been
983- reached. In the former case, [ ` stream.read() ` ] [ stream-read ] will return the
984- available data. In the latter case, [ ` stream.read() ` ] [ stream-read ] will return
985- ` null ` . For instance, in the following example, ` foo.txt ` is an empty file:
979+ If the end of the stream has been reached, calling
980+ [ ` stream.read() ` ] [ stream-read ] will return ` null ` and trigger the ` 'end' `
981+ event. This is also true if there never was any data to be read. For instance,
982+ in the following example, ` foo.txt ` is an empty file:
986983
987984``` js
988985const fs = require (' fs' );
@@ -1003,6 +1000,9 @@ readable: null
10031000end
10041001```
10051002
1003+ In some cases, attaching a listener for the ` 'readable' ` event will cause some
1004+ amount of data to be read into an internal buffer.
1005+
10061006In general, the ` readable.pipe() ` and ` 'data' ` event mechanisms are easier to
10071007understand than the ` 'readable' ` event. However, handling ` 'readable' ` might
10081008result in increased throughput.
0 commit comments