MCPcopy Index your code
hub / github.com/anomalyco/opencode / createEventStream

Function createEventStream

packages/opencode/test/session/llm.test.ts:732–745  ·  view source on GitHub ↗
(chunks: unknown[], includeDone = false)

Source from the content-addressed store, hash-verified

730}
731
732function createEventStream(chunks: unknown[], includeDone = false) {
733 const lines = chunks.map((chunk) => `data: ${typeof chunk === "string" ? chunk : JSON.stringify(chunk)}`)
734 if (includeDone) {
735 lines.push("data: [DONE]")
736 }
737 const payload = lines.join("\n\n") + "\n\n"
738 const encoder = new TextEncoder()
739 return new ReadableStream<Uint8Array>({
740 start(controller) {
741 controller.enqueue(encoder.encode(payload))
742 controller.close()
743 },
744 })
745}
746
747function createEventResponse(chunks: unknown[], includeDone = false) {
748 return new Response(createEventStream(chunks, includeDone), {

Callers 1

createEventResponseFunction · 0.70

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected