MCPcopy Index your code
hub / github.com/streamlit/streamlit / serializeForDisplay

Function serializeForDisplay

frontend/connection/src/utils.ts:128–143  ·  view source on GitHub ↗
(data: unknown)

Source from the content-addressed store, hash-verified

126 * Returns undefined for null, undefined, or non-serializable types.
127 */
128export function serializeForDisplay(data: unknown): string | undefined {
129 if (data === null || data === undefined) {
130 return undefined
131 }
132
133 switch (typeof data) {
134 case "object":
135 return JSON.stringify(data, null, 2)
136 case "string":
137 case "number":
138 case "boolean":
139 return String(data)
140 default:
141 return undefined
142 }
143}
144
145/**
146 * Custom error class to normalize fetch errors into a consistent structure.

Callers 2

utils.test.tsFile · 0.90
doInitPingsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…