MCPcopy Create free account
hub / github.com/arctic-cli/interface / allStructured

Function allStructured

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

matchSequenceFunction · 0.85
matchFunction · 0.70

Tested by

no test coverage detected