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

Function visit

packages/tools/api-diff/src/Json.ts:7–20  ·  view source on GitHub ↗
(input: unknown)

Source from the content-addressed store, hash-verified

5
6export const stableJson = (value: unknown): string => {
7 const visit = (input: unknown): unknown => {
8 if (Array.isArray(input)) {
9 return input.map(visit)
10 }
11 if (input !== null && typeof input === "object") {
12 return Object.fromEntries(
13 Object.entries(input)
14 .filter(([, entry]) => entry !== undefined)
15 .sort(([left], [right]) => left.localeCompare(right))
16 .map(([key, entry]) => [key, visit(entry)])
17 )
18 }
19 return input
20 }
21 return JSON.stringify(visit(value))
22}
23

Callers 2

stableJsonFunction · 0.70
DiscoveryClass · 0.70

Calls 2

filterMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected