| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0defe4e commit a87963d
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -353,7 +353,7 @@ function pipe(src, dst, finish, { end }) { | |||
| 353 | 353 | } | |
| 354 | 354 | }); | |
| 355 | 355 | ||
| 356 | - src.pipe(dst, { end }); | ||
| 356 | + src.pipe(dst, { end: false }); // If end is true we already will have a listener to end dst. | ||
| 357 | 357 | ||
| 358 | 358 | if (end) { | |
| 359 | 359 | // Compat. Before node v10.12.0 stdio used to throw an error so | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1556,3 +1556,38 @@ const tsp = require('timers/promises'); | |||
| 1556 | 1556 | }) | |
| 1557 | 1557 | ); | |
| 1558 | 1558 | } | |
| 1559 | + | ||
| 1560 | + { | ||
| 1561 | + class CustomReadable extends Readable { | ||
| 1562 | + _read() { | ||
| 1563 | + this.push('asd'); | ||
| 1564 | + this.push(null); | ||
| 1565 | + } | ||
| 1566 | + } | ||
| 1567 | + | ||
| 1568 | + class CustomWritable extends Writable { | ||
| 1569 | + constructor() { | ||
| 1570 | + super(); | ||
| 1571 | + this.endCount = 0; | ||
| 1572 | + this.str = ''; | ||
| 1573 | + } | ||
| 1574 | + | ||
| 1575 | + _write(chunk, enc, cb) { | ||
| 1576 | + this.str += chunk; | ||
| 1577 | + cb(); | ||
| 1578 | + } | ||
| 1579 | + | ||
| 1580 | + end() { | ||
| 1581 | + this.endCount += 1; | ||
| 1582 | + super.end(); | ||
| 1583 | + } | ||
| 1584 | + } | ||
| 1585 | + | ||
| 1586 | + const readable = new CustomReadable(); | ||
| 1587 | + const writable = new CustomWritable(); | ||
| 1588 | + | ||
| 1589 | + pipeline(readable, writable, common.mustSucceed(() => { | ||
| 1590 | + assert.strictEqual(writable.str, 'asd'); | ||
| 1591 | + assert.strictEqual(writable.endCount, 1); | ||
| 1592 | + })); | ||
| 1593 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments