| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -586,6 +586,18 @@ added: v11.4.0 | |||
| 586 | 586 | Is `true` if it is safe to call [`writable.write()`][stream-write], which means | |
| 587 | 587 | the stream has not been destroyed, errored or ended. | |
| 588 | 588 | ||
| 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 | + | ||
| 589 | 601 | ##### `writable.writableEnded` | |
| 590 | 602 | ||
| 591 | 603 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -849,7 +849,25 @@ ObjectDefineProperties(Writable.prototype, { | |||
| 849 | 849 | get() { | |
| 850 | 850 | return this._writableState && this._writableState.length; | |
| 851 | 851 | } | |
| 852 | - } | ||
| 852 | + }, | ||
| 853 | + | ||
| 854 | + writableErrored: { | ||
| 855 | + enumerable: false, | ||
| 856 | + get() { | ||
| 857 | + return this._writableState ? this._writableState.errored : null; | ||
| 858 | + } | ||
| 859 | + }, | ||
| 860 | + | ||
| 861 | + writableAborted: { | ||
| 862 | + enumerable: false, | ||
| 863 | + get: function() { | ||
| 864 | + return !!( | ||
| 865 | + this._writableState.writable !== false && | ||
| 866 | + (this._writableState.destroyed || this._writableState.errored) && | ||
| 867 | + !this._writableState.finished | ||
| 868 | + ); | ||
| 869 | + } | ||
| 870 | + }, | ||
| 853 | 871 | }); | |
| 854 | 872 | ||
| 855 | 873 | const destroy = destroyImpl.destroy; | |
| Original file line number | Diff line number | Diff 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 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments