Skip to content

Commit 6fa1f6c

Browse files
committed
stream: add writableAborted
1 parent f217025 commit 6fa1f6c

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

lib/internal/streams/writable.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,17 @@ ObjectDefineProperties(Writable.prototype, {
860860
return this._writableState ? this._writableState.errored : null;
861861
}
862862
},
863+
864+
writableAborted: {
865+
enumerable: false,
866+
get: function() {
867+
return (
868+
!!this._writableState.writable &&
869+
!!(this._writableState.destroyed || this._writableState.errored) &&
870+
!this._writableState.finished
871+
);
872+
}
873+
},
863874
});
864875

865876
const destroy = destroyImpl.destroy;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
const assert = require('assert');
4+
const { Writable } = require('stream');
5+
6+
{
7+
const writable = new Writable({
8+
write() {
9+
}
10+
});
11+
assert.strictEqual(writable.writableAborted, false);
12+
writable.destroy();
13+
assert.strictEqual(writable.writableAborted, true);
14+
}
15+
16+
{
17+
const writable = new writable({
18+
read() {
19+
}
20+
});
21+
assert.strictEqual(writable.writableAborted, false);
22+
writable.end();
23+
writable.destroy()
24+
assert.strictEqual(writable.writableAborted, true);
25+
}

0 commit comments

Comments
 (0)