MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / matchEntries

Function matchEntries

ui/src/lib/entry-model.ts:357–381  ·  view source on GitHub ↗
(
  entries: WireEntryPoints | null,
  query: string,
  limit: number
)

Source from the content-addressed store, hash-verified

355 * being predictable.
356 */
357export function matchEntries(
358 entries: WireEntryPoints | null,
359 query: string,
360 limit: number
361): EntryMatch[] {
362 const needle = query.trim().toLowerCase();
363 if (!entries || needle === '') return [];
364
365 const pools: Array<[EntryMatch['origin'], EntryRow[]]> = [
366 ['route', entries.routes.routed ? entries.routes.items.items.map(routeRow) : []],
367 ['file', entries.files.items.map(fileRow)],
368 ['test', entries.tests.items.map(testRow)],
369 ['hub', entries.hubs.items.map(hubRow)],
370 ];
371
372 const matches: EntryMatch[] = [];
373 for (const [origin, rows] of pools) {
374 for (const row of rows) {
375 if (matches.length >= limit) return matches;
376 const haystack = `${row.method ?? ''} ${row.name} ${row.meta} ${row.title}`.toLowerCase();
377 if (haystack.includes(needle)) matches.push({ row, origin });
378 }
379 }
380 return matches;
381}
382
383/** The location column for a palette entry row — where it came from. */
384export function originLabel(origin: EntryMatch['origin']): string {

Callers 2

buildSearchPaletteFunction · 0.90

Calls 2

mapMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected