(from: string, to: string, tail: Tail)
| 118 | const forks: OrderFork[] = []; |
| 119 | |
| 120 | const join = (from: string, to: string, tail: Tail): void => { |
| 121 | if (from === to) return; |
| 122 | const key = `${from} ${to}`; |
| 123 | const when = tail.when.filter((w, i) => w && tail.when.indexOf(w) === i).join(' && '); |
| 124 | const found = at.get(key); |
| 125 | if (found) { |
| 126 | // Two ways to the same step: the picture keeps both conditions, the way |
| 127 | // a link with several sites does. |
| 128 | if (when !== found.when) found.when = !when || !found.when ? '' : `${found.when} || ${when}`; |
| 129 | for (const r of tail.runs) if (!found.runs.includes(r)) found.runs.push(r); |
| 130 | // Reached as two different arms of one decision: it happens either way, |
| 131 | // and the line stops claiming a side. |
| 132 | if (found.arm !== tail.arm) delete found.arm; |
| 133 | return; |
| 134 | } |
| 135 | const edge: OrderEdge = { from, to, when, runs: [...tail.runs], ...(tail.arm !== undefined ? { arm: tail.arm } : {}) }; |
| 136 | at.set(key, edge); |
| 137 | edges.push(edge); |
| 138 | }; |
| 139 | |
| 140 | const flow = (block: WireBlock, incoming: readonly Tail[], runs: readonly string[]): Tail[] => { |
| 141 | let tails: Tail[] = [...incoming]; |
no test coverage detected