MCPcopy
hub / github.com/Zizzamia/perfume.js / setStepsMap

Function setStepsMap

src/steps/setStepsMap.ts:6–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import { resetSteps, steps } from './steps';
5
6export 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};

Callers 2

initPerfumeFunction · 0.90

Calls 1

resetStepsFunction · 0.90

Tested by

no test coverage detected