( stream: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>, )
| 289 | * ``` |
| 290 | */ |
| 291 | export async function* iterSSEEvents( |
| 292 | stream: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>, |
| 293 | ): AsyncGenerator<ServerSentEvent> { |
| 294 | const decoder = new SSEDecoder(); |
| 295 | for await (const line of iterLines(stream)) { |
| 296 | const event = decoder.decode(line); |
| 297 | if (event !== null) { |
| 298 | yield event; |
| 299 | } |
| 300 | } |
| 301 | } |