Skip to content

Instantly share code, notes, and snippets.

View neet's full-sized avatar

Ryō Igarashi neet

View GitHub Profile
@neet
neet / stream.ts
Created December 23, 2022 03:54 — forked from assaf/stream.ts
Read status updates from Mastodon streaming API
type StreamEvent =
| { event: "update"; status: Status }
| { event: "status.update"; status: Status }
| { event: "delete"; id: string; status?: never };
/**
* Use like this:
* const { events } = await stream(`https://${instance}/api/v1/streaming/public`);
* for await (const { id, status } of events) {
* if (status) … do something …