GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: add writableAborted · nodejs/node@edec730

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • stream.md
  • lib/internal/streams
    • writable.js
  • test/parallel
    • test-stream-writable-aborted.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/stream.md‎

Copy file name to clipboardExpand all lines: doc/api/stream.md
+12Lines changed: 12 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,18 @@ added: v11.4.0
586586
Is `true` if it is safe to call [`writable.write()`][stream-write], which means
587587
the stream has not been destroyed, errored or ended.
588588

589+
##### `writable.writableAborted`
590+
591+
<!-- YAML
592+
added: REPLACEME
593+
-->
594+
595+
> Stability: 1 - Experimental
596+
597+
* {boolean}
598+
599+
Returns whether the stream was destroyed or errored before emitting `'finish'`.
600+
589601
##### `writable.writableEnded`
590602

591603
<!-- YAML
Collapse file

‎lib/internal/streams/writable.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/writable.js
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,18 @@ ObjectDefineProperties(Writable.prototype, {
849849
get() {
850850
return this._writableState && this._writableState.length;
851851
}
852-
}
852+
},
853+
854+
writableAborted: {
855+
enumerable: false,
856+
get: function() {
857+
return !!(
858+
this._writableState.writable !== false &&
859+
(this._writableState.destroyed || this._writableState.errored) &&
860+
!this._writableState.finished
861+
);
862+
}
863+
},
853864
});
854865

855866
const destroy = destroyImpl.destroy;
Collapse file

‎test/parallel/test-stream-writable-aborted.js‎

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

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.