MCPcopy Index your code
hub / github.com/simstudioai/sim / snippetAround

Function snippetAround

apps/sim/lib/logs/log-views.ts:205–214  ·  view source on GitHub ↗
(text: string, regex: RegExp, maxChars: number)

Source from the content-addressed store, hash-verified

203}
204
205function snippetAround(text: string, regex: RegExp, maxChars: number): string {
206 const m = regex.exec(text)
207 const index = m ? m.index : 0
208 const half = Math.floor(maxChars / 2)
209 const start = Math.max(0, index - half)
210 const end = Math.min(text.length, start + maxChars)
211 const prefix = start > 0 ? '…' : ''
212 const suffix = end < text.length ? '…' : ''
213 return `${prefix}${text.slice(start, end)}${suffix}`
214}
215
216function done(state: GrepState): boolean {
217 return state.truncated || state.matches.length >= state.maxMatches

Callers 1

recordIfMatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected