(stream: AsyncIterable<Uint8Array>)
| 674 | } |
| 675 | |
| 676 | async function drainAsync(stream: AsyncIterable<Uint8Array>): Promise<Uint8Array> { |
| 677 | const parts: Uint8Array[] = []; |
| 678 | let total = 0; |
| 679 | for await (const chunk of stream) { |
| 680 | parts.push(chunk); |
| 681 | total += chunk.byteLength; |
| 682 | } |
| 683 | if (parts.length === 0) { |
| 684 | return new Uint8Array(0); |
| 685 | } |
| 686 | if (parts.length === 1) { |
| 687 | return parts[0]; |
| 688 | } |
| 689 | const out = new Uint8Array(total); |
| 690 | let off = 0; |
| 691 | for (const part of parts) { |
| 692 | out.set(part, off); |
| 693 | off += part.byteLength; |
| 694 | } |
| 695 | return out; |
| 696 | } |
| 697 | |
| 698 | async function streamResponse(response: Response, exchange: CopilotRequestExchange): Promise<void> { |
| 699 | await exchange.startResponse({ |
no test coverage detected
searching dependent graphs…