| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 461d9d6 commit c02de65
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,6 +59,9 @@ ObjectSetPrototypeOf(Duplex, Readable); | |||
| 59 | 59 | } | |
| 60 | 60 | } | |
| 61 | 61 | ||
| 62 | + // Use the `destroy` method of `Writable`. | ||
| 63 | + Duplex.prototype.destroy = Writable.prototype.destroy; | ||
| 64 | + | ||
| 62 | 65 | function Duplex(options) { | |
| 63 | 66 | if (!(this instanceof Duplex)) | |
| 64 | 67 | return new Duplex(options); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -238,6 +238,7 @@ const assert = require('assert'); | |||
| 238 | 238 | }); | |
| 239 | 239 | duplex.on('close', common.mustCall()); | |
| 240 | 240 | } | |
| 241 | + | ||
| 241 | 242 | { | |
| 242 | 243 | // Check abort signal | |
| 243 | 244 | const controller = new AbortController(); | |
@@ -255,3 +256,16 @@ const assert = require('assert'); | |||
| 255 | 256 | duplex.on('close', common.mustCall()); | |
| 256 | 257 | controller.abort(); | |
| 257 | 258 | } | |
| 259 | + | ||
| 260 | + { | ||
| 261 | + const duplex = new Duplex({ | ||
| 262 | + read() {}, | ||
| 263 | + write(chunk, enc, cb) { cb(); } | ||
| 264 | + }); | ||
| 265 | + | ||
| 266 | + duplex.cork(); | ||
| 267 | + duplex.write('foo', common.mustCall((err) => { | ||
| 268 | + assert.strictEqual(err.code, 'ERR_STREAM_DESTROYED'); | ||
| 269 | + })); | ||
| 270 | + duplex.destroy(); | ||
| 271 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments