Files
dozzle/assets/utils/events.ts
T
Amir Raminfar de368a1d97 refactor(ui): tighten TypeScript inference, drop redundant casts (#4779)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 15:25:31 +00:00

9 lines
334 B
TypeScript

/**
* Parses the JSON payload of an SSE `MessageEvent`. EventSource listeners
* receive a `MessageEvent` whose `data` is an untyped string, so the parsed
* shape is provided via the type parameter at each call site.
*/
export function parseEventData<T>(event: Event): T {
return JSON.parse((event as MessageEvent).data) as T;
}