( client: object, path: readonly string[], )
| 9 | } |
| 10 | |
| 11 | function 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 | |
| 24 | function buildClientPath(spec: CommandSpec): string[] { |
| 25 | return spec.path.map(seg => (seg.includes('-') ? toCamelCase(seg) : seg)) |
no test coverage detected