From 6328b07bb1c50c69386a307c2d435757051ea639 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Tue, 2 Nov 2021 12:01:48 +0200 Subject: [PATCH] stream: add errored and closed props --- doc/api/stream.md | 44 ++++++++++++++++++- lib/internal/streams/end-of-stream.js | 4 +- lib/internal/streams/readable.js | 18 ++++++-- lib/internal/streams/utils.js | 30 +++++++++++++ lib/internal/streams/writable.js | 15 ++++++- test/parallel/test-stream-finished.js | 4 ++ test/parallel/test-stream-readable-destroy.js | 2 + 7 files changed, 110 insertions(+), 7 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index 91fe70555d0e46..5dc48713fd2dc6 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -456,6 +456,16 @@ further errors except from `_destroy()` may be emitted as `'error'`. Implementors should not override this method, but instead implement [`writable._destroy()`][writable-_destroy]. +##### `writable.closed` + + + +* {boolean} + +Is `true` after `'close'` has been emitted. + ##### `writable.destroyed` + +* {Error} + +Returns error if the stream has been destroyed with an error. + ##### `writable.writableFinished` + +* {boolean} + Is `true` after [`readable.destroy()`][readable-destroy] has been called. ##### `readable.isPaused()` @@ -1346,6 +1377,17 @@ added: v12.9.0 Becomes `true` when [`'end'`][] event is emitted. +##### `readable.readableErrored` + + + +* {Error} + +Returns error if the stream has been destroyed with an error. + ##### `readable.readableFlowing`