MCPcopy Create free account
hub / github.com/MisterBooo/LeetCodeAnimation / compare

Function compare

tools/scripts/review-site-changes.js:68–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

66}
67
68function compare() {
69 const current = loadCurrentManifest().map((item) => ({
70 leetcodeId: item.leetcodeId,
71 sourcePid: item.sourcePid,
72 slug: item.slug,
73 titleZh: item.titleZh,
74 difficulty: item.difficulty,
75 categoryZh: item.categoryZh,
76 }));
77 const next = readProblems(sourceFile)
78 .filter((item) => /^lc\d+$/.test(item.pid) && Number.isInteger(item.num))
79 .map(normalize)
80 .sort((a, b) => a.leetcodeId - b.leetcodeId);
81
82 const currentById = new Map(current.map((item) => [item.leetcodeId, item]));
83 const nextById = new Map(next.map((item) => [item.leetcodeId, item]));
84 const added = next.filter((item) => !currentById.has(item.leetcodeId));
85 const removed = current.filter((item) => !nextById.has(item.leetcodeId));
86 const changed = next.filter((item) => currentById.has(item.leetcodeId) && JSON.stringify(currentById.get(item.leetcodeId)) !== JSON.stringify(item));
87 return { added, removed, changed, nextCount: next.length };
88}
89
90function siteStatus() {
91 const output = sh("git", [

Callers 1

Calls 2

loadCurrentManifestFunction · 0.85
readProblemsFunction · 0.70

Tested by

no test coverage detected