sseio
v0.2.9
Published
Server-side events for TypeScript
Downloads
575
Maintainers
Readme
SSEIO
A lightweight server-side events processing library that adheres to the Server-Sent Events standard. It supports event types, concatenation of chunked data, and more.
Installation
npm install sseio
Usage
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);
}