MCPcopy Create free account
hub / github.com/arktypeio/arktype / matcherOf

Function matcherOf

ark/docs/components/shell/SearchPanel.tsx:470–478  ·  view source on GitHub ↗
(result: SearchResult)

Source from the content-addressed store, hash-verified

468const excerptRadius = 60
469
470const matcherOf = (result: SearchResult) => {
471 const terms = result.terms.filter(Boolean)
472 return terms.length ?
473 new RegExp(
474 `(${terms.map(term => term.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")).join("|")})`,
475 "gi"
476 )
477 : undefined
478}
479
480const marked = (text: string, matcher: RegExp | undefined): ReactNode =>
481 matcher ?

Callers 2

highlightFunction · 0.85
excerptFunction · 0.85

Calls 3

filterMethod · 0.80
replaceMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected