MCPcopy Index your code
hub / github.com/simstudioai/sim / createStreamFromChunks

Function createStreamFromChunks

apps/sim/lib/core/utils/sse.test.ts:13–25  ·  view source on GitHub ↗
(chunks: Uint8Array[])

Source from the content-addressed store, hash-verified

11} from '@/lib/core/utils/sse'
12
13function createStreamFromChunks(chunks: Uint8Array[]): ReadableStream<Uint8Array> {
14 let index = 0
15 return new ReadableStream({
16 pull(controller) {
17 if (index < chunks.length) {
18 controller.enqueue(chunks[index])
19 index++
20 } else {
21 controller.close()
22 }
23 },
24 })
25}
26
27function createSSEChunk(data: object): Uint8Array {
28 return new TextEncoder().encode(`data: ${JSON.stringify(data)}\n\n`)

Callers 2

sse.test.tsFile · 0.85
streamFromStringChunksFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected