GeezerVison is showing github.com — doc: update readable.read() for v26 one-chunk behaviour · nodejs/node@6e90b7c
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/stream.md +12-2Lines changed: 12 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1557,6 +1557,12 @@ closed until the Node.js process exits, regardless of the specified options. |
1557 | 1557 |
|
1558 | 1558 | <!-- YAML |
1559 | 1559 | 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. |
1560 | 1566 | --> |
1561 | 1567 |
|
1562 | 1568 | * `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 |
1573 | 1579 | the stream has ended, in which case all of the data remaining in the internal |
1574 | 1580 | buffer will be returned. |
1575 | 1581 |
|
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. |
1578 | 1588 |
|
1579 | 1589 | The `size` argument must be less than or equal to 1 GiB. |
1580 | 1590 |
|
|