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

Function orderedNeighbours

graph-ui/src/compiler/card-compiler.ts:329–344  ·  view source on GitHub ↗

* Neighbours in their own order, not in the order they arrived. * * The recipe already sorts them, and this sorts them again by the same key. Not * redundant: a compiler whose output depended on the order a caller happened to * assemble a packet in would be one refactor away from producing two d

(entries: readonly NeighbourFact[])

Source from the content-addressed store, hash-verified

327 * set. Idempotent by construction, since the key is the recipe's key.
328 */
329function orderedNeighbours(entries: readonly NeighbourFact[]): NeighbourFact[] {
330 return [...entries].sort((a, b) => {
331 if (a.hop !== b.hop) {
332 return a.hop - b.hop;
333 }
334 if (a.direction !== b.direction) {
335 return a.direction < b.direction ? -1 : 1;
336 }
337 const left = a.qualifiedName ?? a.name;
338 const right = b.qualifiedName ?? b.name;
339 if (left === right) {
340 return 0;
341 }
342 return left < right ? -1 : 1;
343 });
344}
345
346function neighbourDrafts(packet: FactPacket, rank: (kind: CardKind) => number): Draft[] {
347 const subjectName = packet.subject?.name ?? 'the subject';

Callers 1

neighbourDraftsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected