MCPcopy Create free account
hub / github.com/codeaashu/claude-code / extractSnippet

Function extractSnippet

web/lib/workers/search.worker.ts:72–79  ·  view source on GitHub ↗
(text: string, query: string)

Source from the content-addressed store, hash-verified

70}
71
72function extractSnippet(text: string, query: string): string {
73 const lower = text.toLowerCase();
74 const pos = lower.indexOf(query.toLowerCase().split(/\s+/)[0]);
75 if (pos < 0) return text.slice(0, 120) + (text.length > 120 ? "…" : "");
76 const start = Math.max(0, pos - 40);
77 const end = Math.min(text.length, pos + 80);
78 return (start > 0 ? "…" : "") + text.slice(start, end) + (end < text.length ? "…" : "");
79}
80
81function query(
82 q: string,

Callers 1

queryFunction · 0.70

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected