MCPcopy Create free account
hub / github.com/Effect-TS/effect / toStringUnknown

Function toStringUnknown

packages/effect/src/Inspectable.ts:187–196  ·  view source on GitHub ↗
(u: unknown, whitespace: number | string | undefined = 2)

Source from the content-addressed store, hash-verified

185 * @since 2.0.0
186 */
187export const toStringUnknown = (u: unknown, whitespace: number | string | undefined = 2): string => {
188 if (typeof u === "string") {
189 return u
190 }
191 try {
192 return typeof u === "object" ? formatJson(u, { space: whitespace }) : format(u, { space: whitespace })
193 } catch {
194 return String(u)
195 }
196}
197
198/**
199 * A base prototype object that implements the {@link Inspectable} interface.

Callers 1

effect.tsFile · 0.90

Calls 3

formatJsonFunction · 0.90
formatFunction · 0.90
StringInterface · 0.70

Tested by

no test coverage detected