MCPcopy Index your code
hub / github.com/github/copilot-sdk / drainAsync

Function drainAsync

nodejs/src/copilotRequestHandler.ts:676–696  ·  view source on GitHub ↗
(stream: AsyncIterable<Uint8Array>)

Source from the content-addressed store, hash-verified

674}
675
676async 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
698async function streamResponse(response: Response, exchange: CopilotRequestExchange): Promise<void> {
699 await exchange.startResponse({

Callers 1

buildFetchRequestFunction · 0.85

Calls 2

pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…