(node: GraphNode)
| 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); |
no test coverage detected