Skip to content

Commit 6edfe47

Browse files
committed
doc: update readable.read() for v26 one-chunk behaviour
1 parent ae353ec commit 6edfe47

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎doc/api/stream.md‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,12 @@ closed until the Node.js process exits, regardless of the specified options.
15571557

15581558
<!-- YAML
15591559
added: v0.9.4
1560+
changes:
1561+
- version: v26.0.0
1562+
pr-url: https://github.com/nodejs/node/pull/60441
1563+
description: When called without a `size` argument, `readable.read()` now
1564+
returns one buffered chunk per call instead of draining the
1565+
entire internal buffer.
15601566
-->
15611567

15621568
* `size` {number} Optional argument to specify how much data to read.
@@ -1573,8 +1579,12 @@ The optional `size` argument specifies a specific number of bytes to read. If
15731579
the stream has ended, in which case all of the data remaining in the internal
15741580
buffer will be returned.
15751581

1576-
If the `size` argument is not specified, all of the data contained in the
1577-
internal buffer will be returned.
1582+
If the `size` argument is not specified, `readable.read()` returns the next
1583+
buffered chunk, or the next object in object mode. If the entire internal
1584+
buffer is needed in a single call, `readable.read(readable.readableLength)`
1585+
returns all currently buffered data; because data can be buffered internally
1586+
without an explicit `push()`, some cases may additionally require calling
1587+
`readable.read(0)` first to ensure all buffered data is available.
15781588

15791589
The `size` argument must be less than or equal to 1 GiB.
15801590

0 commit comments

Comments
 (0)