parseIncomingMessage function exported ✓ 100.0%

Last updated: 2026-03-01T23:25:47.127Z

Metrics

LOC: 8 Complexity: 5 Params: 2 Coverage: 100.0% (4/4 lines, 7x executed)

Signature

parseIncomingMessage( input: unknown, ): : { type: string; payload?: unknown } | null

Summary

Lightweight message envelope parser — typeof checks only.

Tags

#@param input - Raw message from `chrome.runtime.onMessage`#@returns Parsed `{ type, payload }` or `null` if invalid

Source Code

export function parseIncomingMessage(
  input: unknown,
): { type: string; payload?: unknown } | null {
  if (!input || typeof input !== "object") return null;
  const value = input as { type?: unknown; payload?: unknown };
  if (typeof value.type !== "string" || !value.type) return null;
  return { type: value.type, payload: value.payload };
}

Dependencies (Outgoing)

graph LR parseIncomingMessage["parseIncomingMessage"] SavedForm["SavedForm"] parseIncomingMessage -->|uses| SavedForm style parseIncomingMessage fill:#dbeafe,stroke:#2563eb,stroke-width:2px click parseIncomingMessage "416396348d741ecf.html" click SavedForm "d0449098c37a67b9.html"
TargetType
SavedForm uses

No incoming dependencies.