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

Function toReader

apps/sim/lib/core/utils/sse.ts:89–101  ·  view source on GitHub ↗

* Resolves an SSESource to a reader, reporting whether this call * acquired the lock (and is therefore responsible for releasing it).

(source: SSESource)

Source from the content-addressed store, hash-verified

87 * acquired the lock (and is therefore responsible for releasing it).
88 */
89function toReader(source: SSESource): {
90 reader: ReadableStreamDefaultReader<Uint8Array>
91 ownsLock: boolean
92} {
93 if (source instanceof ReadableStream) {
94 return { reader: source.getReader(), ownsLock: true }
95 }
96 if (source instanceof Response) {
97 if (!source.body) throw new Error('No response body')
98 return { reader: source.body.getReader(), ownsLock: true }
99 }
100 return { reader: source, ownsLock: false }
101}
102
103/**
104 * Strips an optional trailing carriage return from a single SSE line, so both

Callers 1

readSSELinesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected