( condition: string, replacer: (match: string) => Promise<string> )
| 39 | const LOOP_CONDITION_TIMEOUT_MS = 5000 |
| 40 | |
| 41 | async 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 | |
| 58 | export type LoopRoute = typeof EDGE.LOOP_CONTINUE | typeof EDGE.LOOP_EXIT |
| 59 |
no test coverage detected