| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b01bd80 commit 9c0c0e6
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,10 +58,10 @@ function Duplex(options) { | |||
| 58 | 58 | this.writable = false; | |
| 59 | 59 | ||
| 60 | 60 | this.allowHalfOpen = true; | |
| 61 | - if (options && options.allowHalfOpen === false) | ||
| 61 | + if (options && options.allowHalfOpen === false) { | ||
| 62 | 62 | this.allowHalfOpen = false; | |
| 63 | - | ||
| 64 | - this.once('end', onend); | ||
| 63 | + this.once('end', onend); | ||
| 64 | + } | ||
| 65 | 65 | } | |
| 66 | 66 | ||
| 67 | 67 | Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { | |
@@ -96,9 +96,8 @@ Object.defineProperty(Duplex.prototype, 'writableLength', { | |||
| 96 | 96 | ||
| 97 | 97 | // the no-half-open enforcer | |
| 98 | 98 | function onend() { | |
| 99 | - // if we allow half-open state, or if the writable side ended, | ||
| 100 | - // then we're ok. | ||
| 101 | - if (this.allowHalfOpen || this._writableState.ended) | ||
| 99 | + // If the writable side ended, then we're ok. | ||
| 100 | + if (this._writableState.ended) | ||
| 102 | 101 | return; | |
| 103 | 102 | ||
| 104 | 103 | // no more data can be written. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,6 +29,8 @@ const stream = new Duplex({ objectMode: true }); | |||
| 29 | 29 | assert(Duplex() instanceof Duplex); | |
| 30 | 30 | assert(stream._readableState.objectMode); | |
| 31 | 31 | assert(stream._writableState.objectMode); | |
| 32 | + assert(stream.allowHalfOpen); | ||
| 33 | + assert.strictEqual(stream.listenerCount('end'), 0); | ||
| 32 | 34 | ||
| 33 | 35 | let written; | |
| 34 | 36 | let read; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments