MCPcopy
hub / github.com/coder/mux / collectStream

Function collectStream

src/node/utils/gatewayStreamNormalization.test.ts:181–200  ·  view source on GitHub ↗
(chunks: unknown[])

Source from the content-addressed store, hash-verified

179
180describe("normalizeGatewayStreamUsage", () => {
181 async function collectStream(chunks: unknown[]): Promise<unknown[]> {
182 const stream = new ReadableStream({
183 start(controller) {
184 for (const chunk of chunks) {
185 controller.enqueue(chunk);
186 }
187 controller.close();
188 },
189 });
190
191 const result: unknown[] = [];
192 const transformed: ReadableStream<unknown> = stream.pipeThrough(normalizeGatewayStreamUsage());
193 const reader = transformed.getReader();
194 for (;;) {
195 const chunk = await reader.read();
196 if (chunk.done) break;
197 result.push(chunk.value);
198 }
199 return result;
200 }
201
202 it("passes non-finish events through unchanged", async () => {
203 const chunks = [

Calls 3

pushMethod · 0.65
readMethod · 0.45

Tested by

no test coverage detected