MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / performSearch

Function performSearch

docs/script.js:356–385  ·  view source on GitHub ↗
(query)

Source from the content-addressed store, hash-verified

354 };
355
356 const performSearch = async (query) => {
357 const q = query.trim().toLowerCase();
358
359 if (!q || q.length < 2) {
360 hideResults();
361 return;
362 }
363
364 await loadIndex();
365
366 if (!docsIndex || docsIndex.length === 0) {
367 hideResults();
368 return;
369 }
370
371 const matches = docsIndex
372 .map((page) => {
373 const title = (page.title || "").toString();
374 const content = (page.content || "").toString();
375 const haystack = (title + " " + content).toLowerCase();
376 const score = haystack.indexOf(q);
377 return score === -1 ? null : { page, score };
378 })
379 .filter(Boolean)
380 .sort((a, b) => a.score - b.score)
381 .slice(0, 10)
382 .map((entry) => entry.page);
383
384 renderResults(matches, q);
385 };
386
387 let searchDebounce = null;
388

Callers 1

script.jsFile · 0.85

Calls 4

hideResultsFunction · 0.85
loadIndexFunction · 0.85
renderResultsFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected