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

Function getActiveStepsFromNavigationSteps

src/steps/navigationSteps.ts:12–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10 * corresponding end mark was never executed - thus leaving it as a "stale step"
11 */
12export const getActiveStepsFromNavigationSteps = (): Record<
13 string,
14 boolean
15> => {
16 const navigationSteps = getNavigationState();
17 const { startMarkToStepsMap } = steps;
18 const numberOfSteps = Object.keys(navigationSteps).length;
19 if (numberOfSteps === 0) {
20 return {};
21 }
22
23 const activeSteps: Record<string, boolean> = {};
24 const currentNavIndex = numberOfSteps - 1;
25
26 const currentNavStep = getStepsFromNavigation(currentNavIndex);
27
28 Object.keys(currentNavStep).forEach((startMark: string) => {
29 const ongoingSteps = startMarkToStepsMap[startMark] ?? [];
30 Object.keys(ongoingSteps).forEach(step => {
31 activeSteps[step] = true;
32 });
33 });
34
35 // if nav length is >1, then check the nav step prior as well
36 if (numberOfSteps > 1) {
37 const prevNavStep = getStepsFromNavigation(currentNavIndex - 1);
38
39 Object.keys(prevNavStep).forEach((startMark: string) => {
40 const prevNavSteps = startMarkToStepsMap[startMark] ?? [];
41 Object.keys(prevNavSteps).forEach(step => {
42 activeSteps[step] = true;
43 });
44 });
45 }
46
47 return activeSteps;
48};
49
50// start mark for navigationSteps data structure
51export const recordStartMark = (startMark: string) => {

Callers 3

measureStepsFunction · 0.90
navSteps.spec.tsFile · 0.90
trackUJNavigationFunction · 0.85

Calls 2

getNavigationStateFunction · 0.90
getStepsFromNavigationFunction · 0.90

Tested by

no test coverage detected