Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -3084,10 +3084,17 @@ changes:
-->

* `stream` {Readable|Duplex|ReadableStream}
* Returns: {boolean}
* Returns: {boolean|null} - Only returns a `null` if type of `stream.readable` argument passed is not a boolean.

Returns whether the stream is readable.

### `stream.isWritable(stream)`

* `stream` {Writable|Duplex|WritableStream}
* Returns: {boolean|null} - Only returns a `null` if type of `stream.writable` argument passed is not a boolean.

Returns whether the stream is writable.

### `stream.Readable.from(iterable[, options])`

<!-- YAML
Expand Down
6 changes: 3 additions & 3 deletions lib/internal/streams/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,16 @@ function isReadable(stream) {
if (isDestroyed(stream)) return false;
return isReadableNodeStream(stream) &&
stream.readable &&
!isReadableFinished(stream);
!isReadableFinished(stream)
}

function isWritable(stream) {
if (stream && stream[kIsWritable] != null) return stream[kIsWritable];
if (typeof stream?.writable !== 'boolean') return null;
if (typeof stream?.writable !== 'boolean') return null
if (isDestroyed(stream)) return false;
return isWritableNodeStream(stream) &&
stream.writable &&
!isWritableEnded(stream);
!isWritableEnded(stream)
}

function isFinished(stream, opts) {
Expand Down