MCPcopy Create free account
hub / github.com/TanStack/ai / readString

Function readString

packages/ai-grok/src/realtime/adapter.ts:25–31  ·  view source on GitHub ↗

* Runtime-checked field readers for untyped server events. Replace the * drive-by `event.X as string` / `event.X as Record ` casts * with readers that return `undefined` when the shape doesn't match, so a * malformed frame can't throw a TypeError inside `handleServerEvent`.

(
  obj: Record<string, unknown>,
  key: string,
)

Source from the content-addressed store, hash-verified

23 * malformed frame can't throw a TypeError inside `handleServerEvent`.
24 */
25function readString(
26 obj: Record<string, unknown>,
27 key: string,
28): string | undefined {
29 const value = obj[key]
30 return typeof value === 'string' ? value : undefined
31}
32
33function readObject(
34 obj: Record<string, unknown>,

Callers 4

createWebRTCConnectionFunction · 0.70
handleServerEventFunction · 0.70
sendEventFunction · 0.70
flushPendingEventsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected