Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Nov 13, 2021
1 parent 92d6aa6 commit c567585
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 12 additions & 0 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,18 @@ added: v11.4.0
Is `true` if it is safe to call [`writable.write()`][stream-write], which means
the stream has not been destroyed, errored or ended.

##### `writable.writableAborted`

<!-- YAML
added: REPLACEME
-->

> Stability: 1 - Experimental
* {boolean}

Returns whether the stream was destroyed or errored before emitting `'finish'`.

##### `writable.writableEnded`

<!-- YAML
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/streams/writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ ObjectDefineProperties(Writable.prototype, {
enumerable: false,
get: function() {
return !!(
this._writableState.writable &&
this._writableState.writable !== false &&
(this._writableState.destroyed || this._writableState.errored) &&
!this._writableState.finished
);
Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-stream-writable-aborted.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

require('../common');
const assert = require('assert');
const { Writable } = require('stream');

Expand All @@ -14,12 +15,12 @@ const { Writable } = require('stream');
}

{
const writable = new writable({
const writable = new Writable({
read() {
}
});
assert.strictEqual(writable.writableAborted, false);
writable.end();
writable.destroy()
writable.destroy();
assert.strictEqual(writable.writableAborted, true);
}

0 comments on commit c567585

Please sign in to comment.