From a698c49993050491c00d1127236d714c9e8ce2eb Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Thu, 16 Dec 2021 14:32:02 +0100 Subject: [PATCH] stream: add isReadable helper PR-URL: https://github.com/nodejs/node/pull/41199 Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- doc/api/stream.md | 13 +++++++++++++ lib/internal/streams/utils.js | 7 +++++-- lib/internal/webstreams/readablestream.js | 5 +++++ lib/stream.js | 1 + test/parallel/test-whatwg-readablestream.js | 18 ++++++++++++++++-- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index ab285301e1afb0..6280fc740455d5 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -2282,6 +2282,19 @@ added: v17.3.0 Returns whether the stream has encountered an error. +### `stream.isReadable(stream)` + + + +> Stability: 1 - Experimental + +* `stream` {Readable|Duplex|ReadableStream} +* Returns: {boolean} + +Returns whether the stream is readable. + ### `stream.Readable.toWeb(streamReadable)`