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

Function normalizeParallel

apps/sim/lib/workflows/comparison/normalize.ts:158–183  ·  view source on GitHub ↗
(
  parallel: Parallel | null | undefined
)

Source from the content-addressed store, hash-verified

156 * @returns Normalized parallel with only relevant fields
157 */
158export function normalizeParallel(
159 parallel: Parallel | null | undefined
160): NormalizedParallel | null | undefined {
161 if (!parallel) return undefined // Normalize null to undefined
162 const { id, nodes, parallelType, count, distribution } = parallel
163
164 // Sort nodes for consistent comparison (parallel execution doesn't depend on array order)
165 const sortedNodes = [...nodes].sort()
166 const base: NormalizedParallel = {
167 id,
168 nodes: sortedNodes,
169 parallelType,
170 }
171
172 // Only add optional fields if they have non-null/undefined values
173 switch (parallelType) {
174 case 'count':
175 if (count != null) base.count = count
176 break
177 case 'collection':
178 if (distribution != null) base.distribution = distribution
179 break
180 }
181
182 return base
183}
184
185/** Tool configuration with optional UI-only isExpanded field */
186type ToolWithExpanded = Record<string, unknown> & { isExpanded?: boolean }

Callers 3

normalize.test.tsFile · 0.90
normalizeWorkflowStateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected