(pattern: string, index: PlacementIndex)
| 156 | |
| 157 | /** Die Knoten, deren Name das Suchmuster enthaelt. Hoechstens {@link GHOST_LIMIT}. */ |
| 158 | export function ghostsFor(pattern: string, index: PlacementIndex): number[] { |
| 159 | const needle = pattern.trim().toLowerCase(); |
| 160 | if (needle.length < 2) { |
| 161 | return []; |
| 162 | } |
| 163 | const hits: GraphNode[] = []; |
| 164 | for (const node of index.named) { |
| 165 | if (node.name.toLowerCase().includes(needle)) { |
| 166 | hits.push(node); |
| 167 | } |
| 168 | } |
| 169 | return hits |
| 170 | .sort((a, b) => a.name.length - b.name.length || a.id - b.id) |
| 171 | .slice(0, GHOST_LIMIT) |
| 172 | .map((node) => node.id); |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * Die Datei, die ein Befehl nennt und die der Graph kennt. |
no test coverage detected