@@ -1282,9 +1282,11 @@ changes:
1282
1282
-->
1283
1283
1284
1284
The ` 'readable' ` event is emitted when there is data available to be read from
1285
- the stream or when the end of the stream has been reached. Effectively, the
1286
- ` 'readable' ` event indicates that the stream has new information. If data is
1287
- available, [ ` stream.read() ` ] [ stream-read ] will return that data.
1285
+ the stream, up to the configured high water mark (` state.highWaterMark ` ). Effectively,
1286
+ it indicates that the stream has new information within the buffer. If data is available
1287
+ within this buffer, [ ` stream.read() ` ] [ stream-read ] can be called to retrieve that data.
1288
+ Additionally, the ` 'readable' ` event may also be emitted when the end of the stream has been
1289
+ reached.
1288
1290
1289
1291
``` js
1290
1292
const readable = getReadableStreamSomehow ();
@@ -1553,13 +1555,14 @@ readable.on('end', () => {
1553
1555
});
1554
1556
```
1555
1557
1556
- Each call to ` readable.read() ` returns a chunk of data, or ` null ` . The chunks
1557
- are not concatenated. A ` while ` loop is necessary to consume all data
1558
- currently in the buffer. When reading a large file ` .read() ` may return ` null ` ,
1559
- having consumed all buffered content so far, but there is still more data to
1560
- come not yet buffered. In this case a new ` 'readable' ` event will be emitted
1561
- when there is more data in the buffer. Finally the ` 'end' ` event will be
1562
- emitted when there is no more data to come.
1558
+ Each call to ` readable.read() ` returns a chunk of data or ` null ` , signifying
1559
+ that there's no more data to read at that moment. These chunks aren't automatically
1560
+ concatenated. Because a single ` read() ` call does not return all the data, using
1561
+ a while loop may be necessary to continuously read chunks until all data is retrieved.
1562
+ When reading a large file, ` .read() ` might return ` null ` temporarily, indicating
1563
+ that it has consumed all buffered content but there may be more data yet to be
1564
+ buffered. In such cases, a new ` 'readable' ` event is emitted once there's more
1565
+ data in the buffer, and the ` 'end' ` event signifies the end of data transmission.
1563
1566
1564
1567
Therefore to read a file's whole contents from a ` readable ` , it is necessary
1565
1568
to collect chunks across multiple ` 'readable' ` events:
0 commit comments