MCPcopy Create free account
hub / github.com/blockmatic/basilic / getNested

Function getNested

packages/cli/src/run-command.ts:11–22  ·  view source on GitHub ↗
(
  client: object,
  path: readonly string[],
)

Source from the content-addressed store, hash-verified

9}
10
11function getNested(
12 client: object,
13 path: readonly string[],
14): ((opts: object) => Promise<unknown>) | undefined {
15 let obj: unknown = client
16 for (const segment of path) {
17 if (obj === null || obj === undefined || typeof obj !== 'object') return undefined
18 const key = segment.includes('-') ? toCamelCase(segment) : segment
19 obj = (obj as Record<string, unknown>)[key]
20 }
21 return typeof obj === 'function' ? (obj as (opts: object) => Promise<unknown>) : undefined
22}
23
24function buildClientPath(spec: CommandSpec): string[] {
25 return spec.path.map(seg => (seg.includes('-') ? toCamelCase(seg) : seg))

Callers 1

runCommandFunction · 0.85

Calls 1

toCamelCaseFunction · 0.70

Tested by

no test coverage detected