()
| 21 | readAndPause(); |
| 22 | |
| 23 | function readAndPause() { |
| 24 | // Does a on(data) -> pause -> wait -> resume -> on(data) ... loop. |
| 25 | // Expects on(data) to never fire if the stream is paused. |
| 26 | const ondata = common.mustCall((data) => { |
| 27 | rs.pause(); |
| 28 | |
| 29 | expectedData--; |
| 30 | if (expectedData <= 0) |
| 31 | return; |
| 32 | |
| 33 | setImmediate(function() { |
| 34 | rs.removeListener('data', ondata); |
| 35 | readAndPause(); |
| 36 | rs.resume(); |
| 37 | }); |
| 38 | }, 1); // Only call ondata once |
| 39 | |
| 40 | rs.on('data', ondata); |
| 41 | } |
| 42 | |
| 43 | { |
| 44 | const readable = new Readable({ |
no test coverage detected