MCPcopy Create free account
hub / github.com/bywwcnll/StreamPanel / normalizeMessage

Function normalizeMessage

devtools/panel.bundle.js:2862–2882  ·  view source on GitHub ↗
(message, index)

Source from the content-addressed store, hash-verified

2860 }
2861
2862 function normalizeMessage(message, index) {
2863 const fallbackTimestamp = Date.now();
2864
2865 if (!message || typeof message !== 'object') {
2866 return {
2867 id: index + 1,
2868 eventType: 'message',
2869 data: String(message ?? ''),
2870 lastEventId: '',
2871 timestamp: fallbackTimestamp
2872 };
2873 }
2874
2875 return {
2876 id: Number.isFinite(Number(message.id)) ? Number(message.id) : index + 1,
2877 eventType: message.eventType || 'message',
2878 data: typeof message.data === 'string' ? message.data : JSON.stringify(message.data ?? ''),
2879 lastEventId: message.lastEventId || '',
2880 timestamp: parseTimestamp(message.timestamp, fallbackTimestamp)
2881 };
2882 }
2883
2884 function parseTimestamp(value, fallback) {
2885 if (typeof value === 'number' && Number.isFinite(value)) {

Callers 1

normalizeConnectionFunction · 0.70

Calls 1

parseTimestampFunction · 0.70

Tested by

no test coverage detected