()
| 106 | } |
| 107 | |
| 108 | async pump(): Promise<boolean> { |
| 109 | const chunkResult = await this.upstream.next(); |
| 110 | let chunk; |
| 111 | if (chunkResult.done) { |
| 112 | return false; |
| 113 | } else { |
| 114 | chunk = chunkResult.value; |
| 115 | } |
| 116 | |
| 117 | let text: string; |
| 118 | if (env().get('IS_BROWSER')) { |
| 119 | text = this.decoder.decode(chunk, {stream: true}); |
| 120 | } else { |
| 121 | text = this.decoder.write(Buffer.from(chunk.buffer)); |
| 122 | } |
| 123 | this.outputQueue.push(text); |
| 124 | return true; |
| 125 | } |
| 126 | } |