()
| 50 | } |
| 51 | |
| 52 | readStart() { |
| 53 | if (this.closed) { |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | if (!this.started) { |
| 58 | this._intervalHandle = localSetInterval(writeChunk, 2); |
| 59 | this.started = true; |
| 60 | } |
| 61 | |
| 62 | if (this.paused) { |
| 63 | this._intervalHandle = localSetInterval(writeChunk, 2); |
| 64 | this.paused = false; |
| 65 | } |
| 66 | |
| 67 | const source = this; |
| 68 | function writeChunk() { |
| 69 | if (source.paused) { |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | source.pushed++; |
| 74 | |
| 75 | if (source.toPush > 0 && source.pushed > source.toPush) { |
| 76 | if (source._intervalHandle) { |
| 77 | localClearInterval(source._intervalHandle); |
| 78 | source._intervalHandle = undefined; |
| 79 | } |
| 80 | source.closed = true; |
| 81 | source.onend(); |
| 82 | } else { |
| 83 | source.ondata(randomChunk(128)); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | readStop() { |
| 89 | if (this.paused) { |
no outgoing calls
no test coverage detected