Skip to content

Commit

Permalink
chore: daily development
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Jan 14, 2025
1 parent 0a56652 commit abd01c6
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion packages/canyon-data/src/coverage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
function genHitByMap(mapValue:any) {
return {
s: Object.entries(mapValue.statementMap).reduce((accInside, [keyInside]) => {
// @ts-ignore
accInside[keyInside] = 0;
return accInside;
}, {}),
f: Object.entries(mapValue.fnMap).reduce((accInside, [keyInside]) => {
// @ts-ignore
accInside[keyInside] = 0;
return accInside;
}, {}),
b: Object.entries(mapValue.branchMap).reduce(
(accInside, [keyInside, valueInside]: any) => {
// @ts-ignore
accInside[keyInside] = Array(valueInside.length).fill(0);
return accInside;
},
{},
),
}
}
export const reorganizeCompleteCoverageObjects = (
map: {
[key: string]: object;
Expand All @@ -9,13 +31,20 @@ export const reorganizeCompleteCoverageObjects = (
// 重组的时候以map为基准,map可能是只查询一部分。
const obj = {};
for (const mapKey in map) {
if (map[mapKey] && hit[mapKey]) {
if (hit[mapKey]) {
// @ts-ignore
obj[mapKey] = {
...map[mapKey],
...hit[mapKey],
path: mapKey,
}
} else {
// @ts-ignore
obj[mapKey] = {
...map[mapKey],
...genHitByMap(map[mapKey]),
path: mapKey,
}
}
}
return obj;
Expand Down

0 comments on commit abd01c6

Please sign in to comment.