From 1150963217f99a970ba2dda8d6cfcc6fc6a84eea 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 ad8d5c49c04d2f..9957586fa605be 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -2228,6 +2228,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)`