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

Function stringifyCircular

packages/effect/src/Inspectable.ts:221–237  ·  view source on GitHub ↗
(obj: unknown, whitespace?: number | string | undefined)

Source from the content-addressed store, hash-verified

219 * @since 2.0.0
220 */
221export const stringifyCircular = (obj: unknown, whitespace?: number | string | undefined): string => {
222 let cache: Array<unknown> = []
223 const retVal = JSON.stringify(
224 obj,
225 (_key, value) =>
226 typeof value === "object" && value !== null
227 ? cache.includes(value)
228 ? undefined // circular reference
229 : cache.push(value) && (redactableState.fiberRefs !== undefined && isRedactable(value)
230 ? value[symbolRedactable](redactableState.fiberRefs)
231 : value)
232 : value,
233 whitespace
234 )
235 ;(cache as any) = undefined
236 return retVal
237}
238
239/**
240 * @since 3.10.0

Callers 2

toStringUnknownFunction · 0.85
prettyErrorMessageFunction · 0.85

Calls 1

isRedactableFunction · 0.85

Tested by

no test coverage detected