sseio
v0.8.3
Published
Server-side events for TypeScript
Maintainers
Readme
SSEIO
A lightweight Server-Sent Events processing library that adheres to the Server-Sent Events standard. It supports event types, concatenation of chunked data, and more.
Installation
npm install sseioUsage
Receiving raw data from a server
import { SseReader } from "sseio";
const response = await fetch("http://localhost:3000/sse");
if (!response.body) {
throw new Error("No response body with stream");
}
const sse_reader = new SseReader(response.body.getReader());
for await (const event of sse_reader.next_event()) {
console.log(event.type, event.data);
}