(steps)
| 202 | } |
| 203 | |
| 204 | function flattenSteps(steps) { |
| 205 | const out = [] |
| 206 | let prevChain = [] |
| 207 | |
| 208 | for (const step of steps) { |
| 209 | const chain = metaChain(step) |
| 210 | |
| 211 | let common = 0 |
| 212 | while (common < chain.length && common < prevChain.length && chain[common].key === prevChain[common].key) common++ |
| 213 | |
| 214 | for (let d = common; d < chain.length; d++) { |
| 215 | out.push({ depth: d, step: chain[d].step }) |
| 216 | } |
| 217 | out.push({ depth: chain.length, step }) |
| 218 | prevChain = chain |
| 219 | } |
| 220 | |
| 221 | return out |
| 222 | } |
| 223 | |
| 224 | function metaChain(step) { |
| 225 | const chain = [] |
no test coverage detected