MCPcopy Create free account
hub / github.com/pomber/code-surfer / getStepIds

Function getStepIds

packs/step-parser/src/differ.ts:67–86  ·  view source on GitHub ↗
(
  lineIds: number[],
  oldStepIds: number[] = [],
  oldStepCode: string = "",
  newStepCode: string = ""
)

Source from the content-addressed store, hash-verified

65}
66
67function getStepIds(
68 lineIds: number[],
69 oldStepIds: number[] = [],
70 oldStepCode: string = "",
71 newStepCode: string = ""
72): number[] {
73 const changes = getChanges(oldStepCode, newStepCode);
74
75 const newStepIds = oldStepIds.slice(0);
76 changes.forEach(({ op, count, index }) => {
77 if (op === "-") {
78 newStepIds.splice(index, count);
79 } else {
80 const afterId = newStepIds[index - 1];
81 const newIds = generateIds(lineIds, afterId, count);
82 newStepIds.splice(index, 0, ...newIds);
83 }
84 });
85 return newStepIds;
86}
87
88export function linesDiff(codeList: string[]) {
89 const steps: number[][] = [];

Callers 1

linesDiffFunction · 0.85

Calls 2

getChangesFunction · 0.85
generateIdsFunction · 0.85

Tested by

no test coverage detected