MCPcopy Index your code
hub / github.com/Effect-TS/effect / toJSON

Function toJSON

packages/effect/src/Inspectable.ts:33–47  ·  view source on GitHub ↗
(x: unknown)

Source from the content-addressed store, hash-verified

31 * @since 2.0.0
32 */
33export const toJSON = (x: unknown): unknown => {
34 try {
35 if (
36 Predicate.hasProperty(x, "toJSON") && Predicate.isFunction(x["toJSON"]) &&
37 x["toJSON"].length === 0
38 ) {
39 return x.toJSON()
40 } else if (Array.isArray(x)) {
41 return x.map(toJSON)
42 }
43 } catch {
44 return {}
45 }
46 return redact(x)
47}
48
49const CIRCULAR = "[Circular]"
50

Callers

nothing calls this directly

Calls 3

redactFunction · 0.85
toJSONMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected