Skip to content

Commit 6bb3112

Browse files
committed
doc: make unshift doc compliant with push doc
readable.unshift() also allows to pass null and end stream readable.push() don't allow null when in object mode
1 parent 1592d0a commit 6bb3112

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

doc/api/stream.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,13 +1244,15 @@ changes:
12441244
description: The `chunk` argument can now be a `Uint8Array` instance.
12451245
-->
12461246

1247-
* `chunk` {Buffer|Uint8Array|string|any} Chunk of data to unshift onto the
1247+
* `chunk` {Buffer|Uint8Array|string|null|any} Chunk of data to unshift onto the
12481248
read queue. For streams not operating in object mode, `chunk` must be a
12491249
string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be
12501250
any JavaScript value other than `null`.
12511251
* `encoding` {string} Encoding of string chunks. Must be a valid
12521252
`Buffer` encoding, such as `'utf8'` or `'ascii'`.
12531253

1254+
Passing chunk as null signals the end of the stream (EOF), after which no more data can be written.
1255+
12541256
The `readable.unshift()` method pushes a chunk of data back into the internal
12551257
buffer. This is useful in certain situations where a stream is being consumed by
12561258
code that needs to "un-consume" some amount of data that it has optimistically
@@ -2028,7 +2030,7 @@ changes:
20282030
* `chunk` {Buffer|Uint8Array|string|null|any} Chunk of data to push into the
20292031
read queue. For streams not operating in object mode, `chunk` must be a
20302032
string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be
2031-
any JavaScript value.
2033+
any JavaScript value other than `null`..
20322034
* `encoding` {string} Encoding of string chunks. Must be a valid
20332035
`Buffer` encoding, such as `'utf8'` or `'ascii'`.
20342036
* Returns: {boolean} `true` if additional chunks of data may continue to be

0 commit comments

Comments
 (0)