MCPcopy Index your code
hub / github.com/simstudioai/sim / normalizeValue

Function normalizeValue

apps/sim/lib/workflows/comparison/normalize.ts:61–84  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

59 * @returns A normalized version of the value with sorted keys and no null/undefined fields
60 */
61export function normalizeValue(value: unknown): unknown {
62 // Treat null and undefined as equivalent - both become undefined (omitted from objects)
63 if (value === null || value === undefined) {
64 return undefined
65 }
66
67 if (typeof value !== 'object') {
68 return value
69 }
70
71 if (Array.isArray(value)) {
72 return value.map(normalizeValue)
73 }
74
75 const sorted: Record<string, unknown> = {}
76 for (const key of Object.keys(value as Record<string, unknown>).sort()) {
77 const normalized = normalizeValue((value as Record<string, unknown>)[key])
78 // Only include non-null/undefined values
79 if (normalized !== undefined) {
80 sorted[key] = normalized
81 }
82 }
83 return sorted
84}
85
86/**
87 * Generates a normalized JSON string for comparison

Callers 4

normalize.test.tsFile · 0.90
normalizedStringifyFunction · 0.85
normalizeWorkflowStateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected