(chunks: Uint8Array[])
| 11 | } from '@/lib/core/utils/sse' |
| 12 | |
| 13 | function 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 | |
| 27 | function createSSEChunk(data: object): Uint8Array { |
| 28 | return new TextEncoder().encode(`data: ${JSON.stringify(data)}\n\n`) |
no outgoing calls
no test coverage detected