mirror of
https://github.com/amir20/dozzle.git
synced 2026-06-23 04:10:12 +00:00
de368a1d97
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9 lines
334 B
TypeScript
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;
|
|
}
|