MCPcopy
hub / github.com/midrender/revideo / uniqueCommon

Function uniqueCommon

packages/2d/src/lib/code/diff.ts:84–108  ·  view source on GitHub ↗

* Finds all the unique common entries between aArray[aStart...aEnd] and * bArray[bStart...bEnd], inclusive. This function uses findUnique to pare * down the aArray and bArray ranges first, before then walking the * comparison between the two arrays. * * * @param aArray - The origin

(
    aArray: string[],
    aStart: number,
    aEnd: number,
    bArray: string[],
    bStart: number,
    bEnd: number,
  )

Source from the content-addressed store, hash-verified

82 * matching uniqe lines.
83 */
84 function uniqueCommon(
85 aArray: string[],
86 aStart: number,
87 aEnd: number,
88 bArray: string[],
89 bStart: number,
90 bEnd: number,
91 ): Map<string, Subsequence> {
92 const aUnique = findUnique(aArray, aStart, aEnd);
93 const bUnique = findUnique(bArray, bStart, bEnd);
94
95 return [...aUnique.entries()].reduce<Map<string, Subsequence>>(
96 (paired, [key, value]) => {
97 const bIndex = bUnique.get(key);
98 if (bIndex !== undefined) {
99 paired.set(key, {
100 aIndex: value,
101 bIndex,
102 });
103 }
104 return paired;
105 },
106 new Map(),
107 );
108 }
109
110 /**
111 * Takes a map from the unique common lines between two arrays and determines

Callers 2

addSubMatchFunction · 0.85
recurseLCSFunction · 0.85

Calls 3

findUniqueFunction · 0.85
setMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected