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

Function toStringUnknown

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

Source from the content-addressed store, hash-verified

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

Callers 1

effect.tsFile · 0.90

Calls 3

formatJsonFunction · 0.90
formatFunction · 0.90
StringFunction · 0.70

Tested by

no test coverage detected