From 7cef7699e3f157be0ea31fb185d45ef9a040fe91 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 eeabdc1bf63964..1bf7eaef6c723e 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -2211,6 +2211,19 @@ added: REPLACEME 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)`