| 23 | Rest of line`; |
| 24 | |
| 25 | function oldWay() { |
| 26 | const readable = new Readable({ |
| 27 | objectMode: true, |
| 28 | read: () => { |
| 29 | this.resume(); |
| 30 | }, |
| 31 | destroy: (err, cb) => { |
| 32 | this.off('line', lineListener); |
| 33 | this.off('close', closeListener); |
| 34 | this.close(); |
| 35 | cb(err); |
| 36 | }, |
| 37 | }); |
| 38 | const lineListener = (input) => { |
| 39 | if (!readable.push(input)) { |
| 40 | // TODO(rexagod): drain to resume flow |
| 41 | this.pause(); |
| 42 | } |
| 43 | }; |
| 44 | const closeListener = () => { |
| 45 | readable.push(null); |
| 46 | }; |
| 47 | const errorListener = (err) => { |
| 48 | readable.destroy(err); |
| 49 | }; |
| 50 | this.on('error', errorListener); |
| 51 | this.on('line', lineListener); |
| 52 | this.on('close', closeListener); |
| 53 | return readable[Symbol.asyncIterator](); |
| 54 | } |
| 55 | |
| 56 | function getLoremIpsumStream(repetitions) { |
| 57 | const readable = Readable({ |