()
| 4 | import { resetSteps, steps } from './steps'; |
| 5 | |
| 6 | export const setStepsMap = () => { |
| 7 | if (!config.steps) { |
| 8 | return; |
| 9 | } |
| 10 | resetSteps(); |
| 11 | |
| 12 | Object.entries<IStepConfig<string>>(config.steps).forEach( |
| 13 | ([step, { marks }]) => { |
| 14 | const startMark = marks[0]; |
| 15 | const endMark = marks[1]; |
| 16 | // getting the current steps associated with the current start mark |
| 17 | const currentStartMarks = steps.startMarkToStepsMap[startMark] ?? {}; |
| 18 | currentStartMarks[step] = true; |
| 19 | steps.startMarkToStepsMap[startMark] = currentStartMarks; |
| 20 | |
| 21 | if (!steps.finalMarkToStepsMap[endMark]) { |
| 22 | // insert when top level end mark is not present |
| 23 | steps.finalMarkToStepsMap[endMark] = { [startMark]: [step] }; |
| 24 | } else { |
| 25 | // insert when end mark and start mark are both present |
| 26 | const currentSteps = steps.finalMarkToStepsMap[endMark][startMark] || []; |
| 27 | currentSteps.push(step); |
| 28 | steps.finalMarkToStepsMap[endMark][startMark] = currentSteps; |
| 29 | } |
| 30 | }, |
| 31 | ); |
| 32 | }; |
no test coverage detected