MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / rank

Function rank

graph-ui/src/galaxy/ScopePathControls.tsx:25–28  ·  view source on GitHub ↗
(node: GraphNode)

Source from the content-addressed store, hash-verified

23 // Name matches first, as in the node search: exact, prefix, anywhere, then path or qualified name.
24 // A Branch node is found by its shown name and by its name in the index (round 4, N1).
25 const rank = (node: GraphNode) => Math.min(...[graphNodeName(node), node.name].map(value => {
26 const name = value.toLocaleLowerCase();
27 return name === needle ? 0 : name.startsWith(needle) ? 1 : name.includes(needle) ? 2 : 3;
28 }));
29 return nodes.filter(node => !needle || [graphNodeName(node), node.name, node.qualified_name, nodeFilePath(node)]
30 .some(value => value?.toLocaleLowerCase().includes(needle)))
31 .sort((a, b) => rank(a) - rank(b) || graphNodeName(a).localeCompare(graphNodeName(b)) || a.id - b.id);

Callers 5

PathPickerFunction · 0.70
subjectDraftsFunction · 0.50
neighbourDraftsFunction · 0.50
compileCardsFunction · 0.50

Calls 1

graphNodeNameFunction · 0.90

Tested by

no test coverage detected