MCPcopy Index your code
hub / github.com/simstudioai/sim / readSSEEvents

Function readSSEEvents

apps/sim/lib/core/utils/sse.ts:179–197  ·  view source on GitHub ↗
(
  source: SSESource,
  options: ReadSSEEventsOptions<T>
)

Source from the content-addressed store, hash-verified

177 * @param options - The `onEvent` callback plus optional `signal`/`onParseError`.
178 */
179export async function readSSEEvents<T = unknown>(
180 source: SSESource,
181 options: ReadSSEEventsOptions<T>
182): Promise<void> {
183 const { onEvent, onParseError, signal } = options
184 await readSSELines(source, {
185 signal,
186 onData: (data) => {
187 let parsed: T
188 try {
189 parsed = JSON.parse(data) as T
190 } catch (error) {
191 onParseError?.(data, error)
192 return
193 }
194 return onEvent(parsed)
195 },
196 })
197}
198
199/**
200 * Options for reading SSE stream

Callers 1

sse.test.tsFile · 0.90

Calls 2

readSSELinesFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected