(value: unknown, path: PathSegment[])
| 51 | } |
| 52 | |
| 53 | function getNested(value: unknown, path: PathSegment[]): unknown { |
| 54 | let current: unknown = value |
| 55 | for (const segment of path) { |
| 56 | if (typeof segment === 'number') { |
| 57 | if (!Array.isArray(current) || segment >= current.length) { |
| 58 | return undefined |
| 59 | } |
| 60 | current = current[segment] |
| 61 | continue |
| 62 | } |
| 63 | if (!isRecord(current)) { |
| 64 | return undefined |
| 65 | } |
| 66 | current = current[segment] |
| 67 | } |
| 68 | return current |
| 69 | } |
| 70 | |
| 71 | function getFirstString(value: unknown, paths: PathSegment[][]): string | null { |
| 72 | for (const path of paths) { |
no test coverage detected