| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8b1afe3 commit 4ad48d9
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -272,9 +272,11 @@ function constructNT(stream) { | |||
| 272 | 272 | } | |
| 273 | 273 | ||
| 274 | 274 | try { | |
| 275 | - stream._construct(onConstruct); | ||
| 275 | + stream._construct((err) => { | ||
| 276 | + process.nextTick(onConstruct, err); | ||
| 277 | + }); | ||
| 276 | 278 | } catch (err) { | |
| 277 | - onConstruct(err); | ||
| 279 | + process.nextTick(onConstruct, err); | ||
| 278 | 280 | } | |
| 279 | 281 | } | |
| 280 | 282 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -468,3 +468,27 @@ const { PassThrough, Transform } = require('stream'); | |||
| 468 | 468 | assert.strictEqual(ended, true); | |
| 469 | 469 | })); | |
| 470 | 470 | } | |
| 471 | + | ||
| 472 | + { | ||
| 473 | + const s = new Transform({ | ||
| 474 | + objectMode: true, | ||
| 475 | + construct(callback) { | ||
| 476 | + this.push('header from constructor'); | ||
| 477 | + callback(); | ||
| 478 | + }, | ||
| 479 | + transform: (row, encoding, callback) => { | ||
| 480 | + callback(null, row); | ||
| 481 | + }, | ||
| 482 | + }); | ||
| 483 | + | ||
| 484 | + const expected = [ | ||
| 485 | + 'header from constructor', | ||
| 486 | + 'firstLine', | ||
| 487 | + 'secondLine', | ||
| 488 | + ]; | ||
| 489 | + s.on('data', common.mustCall((data) => { | ||
| 490 | + assert.strictEqual(data.toString(), expected.shift()); | ||
| 491 | + }, 3)); | ||
| 492 | + s.write('firstLine'); | ||
| 493 | + process.nextTick(() => s.write('secondLine')); | ||
| 494 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments