MCPcopy Index your code
hub / github.com/npmx-dev/npmx.dev / flattenTree

Function flattenTree

server/utils/compare.ts:29–37  ·  view source on GitHub ↗
(tree: PackageFileTree[])

Source from the content-addressed store, hash-verified

27
28/** Flatten a file tree into a map of path -> node */
29export function flattenTree(tree: PackageFileTree[]): Map<string, PackageFileTree> {
30 const result = new Map<string, PackageFileTree>()
31
32 traverse(tree, node => {
33 result.set(node.path, node)
34 })
35
36 return result
37}
38
39const hasChanged = (fromNode: PackageFileTree, toNode: PackageFileTree): boolean => {
40 // Prefer strong hash comparison when both hashes are available

Callers 1

compareFileTreesFunction · 0.85

Calls 2

traverseFunction · 0.70
setMethod · 0.65

Tested by

no test coverage detected