From b59c513c3152f544a8b6088911104429d1a39c26 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Thu, 9 Dec 2021 09:15:12 +0100 Subject: [PATCH] stream: add isErrored helper Refs: https://github.com/nodejs/undici/pull/1134 PR-URL: https://github.com/nodejs/node/pull/41121 Reviewed-By: Matteo Collina Reviewed-By: Minwoo Jung --- doc/api/stream.md | 13 ++++++++++++ lib/internal/streams/utils.js | 20 ++++++++++++++++--- lib/internal/webstreams/readablestream.js | 5 +++++ lib/stream.js | 4 +++- test/parallel/test-stream-readable-didRead.js | 7 +++++-- test/parallel/test-whatwg-readablestream.js | 18 ++++++++++++++++- tools/doc/type-parser.mjs | 4 ++++ 7 files changed, 64 insertions(+), 7 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index c2f5a6fe43ca68..1814efbc6d68a9 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -2171,6 +2171,19 @@ added: v16.8.0 Returns whether the stream has been read from or cancelled. +### `stream.isErrored(stream)` + + + +> Stability: 1 - Experimental + +* `stream` {Readable|Writable|Duplex|WritableStream|ReadableStream} +* Returns: {boolean} + +Returns whether the stream has encountered an error. + ### `stream.Readable.toWeb(streamReadable)`