(lines: unknown[], { sse = false } = {})
| 37 | ]; |
| 38 | |
| 39 | function commandCodeStream(lines: unknown[], { sse = false } = {}) { |
| 40 | const text = lines |
| 41 | .map((line) => { |
| 42 | const json = JSON.stringify(line); |
| 43 | return sse ? `data: ${json}\n\n` : `${json}\n`; |
| 44 | }) |
| 45 | .join(""); |
| 46 | return new Response(text, { status: 200, headers: { "Content-Type": "application/x-ndjson" } }); |
| 47 | } |
| 48 | |
| 49 | function toPlainHeaders(headers: Headers | Record<string, string>) { |
| 50 | if (headers instanceof Headers) return Object.fromEntries(headers.entries()); |
no outgoing calls
no test coverage detected