(ctrl)
| 256 | function streamResponse(gen: AsyncGenerator<string>, status = 200) { |
| 257 | const stream = new ReadableStream({ |
| 258 | async start(ctrl) { |
| 259 | try { |
| 260 | for await (const chunk of gen) { |
| 261 | ctrl.enqueue(new TextEncoder().encode(chunk)); |
| 262 | } |
| 263 | ctrl.close(); |
| 264 | } catch (e) { |
| 265 | ctrl.error(e); |
| 266 | } |
| 267 | }, |
| 268 | }); |
| 269 | return new Response(stream, { |
| 270 | status, |
nothing calls this directly
no outgoing calls
no test coverage detected