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

Function replaceLoopConditionReferences

apps/sim/executor/orchestrators/loop.ts:41–56  ·  view source on GitHub ↗
(
  condition: string,
  replacer: (match: string) => Promise<string>
)

Source from the content-addressed store, hash-verified

39const LOOP_CONDITION_TIMEOUT_MS = 5000
40
41async function replaceLoopConditionReferences(
42 condition: string,
43 replacer: (match: string) => Promise<string>
44): Promise<string> {
45 const pattern = createReferencePattern()
46 let cursor = 0
47 let result = ''
48 for (const match of condition.matchAll(pattern)) {
49 const fullMatch = match[0]
50 const index = match.index ?? 0
51 result += condition.slice(cursor, index)
52 result += isLikelyReferenceSegment(fullMatch) ? await replacer(fullMatch) : fullMatch
53 cursor = index + fullMatch.length
54 }
55 return result + condition.slice(cursor)
56}
57
58export type LoopRoute = typeof EDGE.LOOP_CONTINUE | typeof EDGE.LOOP_EXIT
59

Callers 1

Calls 2

createReferencePatternFunction · 0.90
isLikelyReferenceSegmentFunction · 0.90

Tested by

no test coverage detected