MCPcopy Index your code
hub / github.com/anomalyco/opencode / allStructured

Function allStructured

packages/opencode/src/util/wildcard.ts:33–45  ·  view source on GitHub ↗
(input: { head: string; tail: string[] }, patterns: Record<string, any>)

Source from the content-addressed store, hash-verified

31}
32
33export function allStructured(input: { head: string; tail: string[] }, patterns: Record<string, any>) {
34 const sorted = pipe(patterns, Object.entries, sortBy([([key]) => key.length, "asc"], [([key]) => key, "asc"]))
35 let result = undefined
36 for (const [pattern, value] of sorted) {
37 const parts = pattern.split(/\s+/)
38 if (!match(input.head, parts[0])) continue
39 if (parts.length === 1 || matchSequence(input.tail, parts.slice(1))) {
40 result = value
41 continue
42 }
43 }
44 return result
45}
46
47function matchSequence(items: string[], patterns: string[]): boolean {
48 if (patterns.length === 0) return true

Callers

nothing calls this directly

Calls 3

pipeFunction · 0.85
matchSequenceFunction · 0.85
matchFunction · 0.70

Tested by

no test coverage detected