MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / parseEvent

Function parseEvent

src/lib/sse-io.ts:68–79  ·  view source on GitHub ↗
(event: MessageEvent)

Source from the content-addressed store, hash-verified

66export type EventFormatter = (eventData: LiveLogMessage) => EventFormat
67
68export const parseEvent = (event: MessageEvent): LiveLogMessage => {
69 try {
70 const message = JSON.parse(event.data)
71 if (isLiveLogMessage(message)) {
72 return message
73 } else {
74 throw Error('Unexpected log message type.')
75 }
76 } catch (error) {
77 throw Error(`Unable to parse received event ${event.data}.`, { cause: error })
78 }
79}
80
81/**
82 * Log received Server-sent event data to the console.

Callers 2

handlerFunction · 0.85
sse-io.test.tsFile · 0.85

Calls 1

isLiveLogMessageFunction · 0.85

Tested by

no test coverage detected