Skip to content

Commit 29661fd

Browse files
committed
fix nits
1 parent e0dfdab commit 29661fd

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

server/utils/compare.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import type { PackageFileTree, DependencyChange, FileChange, CompareResponse } f
44
/** Maximum number of files to include in comparison */
55
const MAX_FILES_COMPARE = 1000
66

7+
function traverse(nodes: PackageFileTree[], result: Map<string, PackageFileTree>) {
8+
for (const node of nodes) {
9+
result.set(node.path, node)
10+
if (node.children) {
11+
traverse(node.children, result)
12+
}
13+
}
14+
}
15+
716
/** Flatten a file tree into a map of path -> node */
817
export function flattenTree(tree: PackageFileTree[]): Map<string, PackageFileTree> {
918
const result = new Map<string, PackageFileTree>()
1019

11-
function traverse(nodes: PackageFileTree[]) {
12-
for (const node of nodes) {
13-
result.set(node.path, node)
14-
if (node.children) {
15-
traverse(node.children)
16-
}
17-
}
18-
}
19-
20-
traverse(tree)
20+
traverse(tree, result)
2121
return result
2222
}
2323

@@ -98,7 +98,7 @@ export function compareFileTrees(
9898
for (const [path, fromNode] of fromFiles) {
9999
if (fromNode.type === 'directory') continue
100100

101-
if (added.length + removed.length + modified.length >= MAX_FILES_COMPARE) {
101+
if (overLimit()) {
102102
truncated = true
103103
break
104104
}

0 commit comments

Comments
 (0)