(obj: any, path: string, fallback?: any)
| 36 | } |
| 37 | |
| 38 | export function getDotPath(obj: any, path: string, fallback?: any): any { |
| 39 | if (typeof path !== 'string') return fallback |
| 40 | |
| 41 | const idx = path.indexOf('.') |
| 42 | |
| 43 | if (idx === -1) { |
| 44 | return obj?.[path] ?? fallback |
| 45 | } |
| 46 | |
| 47 | const key = path.slice(0, idx) |
| 48 | const nextPath = path.slice(idx + 1) |
| 49 | |
| 50 | const checkValue = obj?.[key]?.[nextPath] |
| 51 | if (checkValue) { |
| 52 | return checkValue |
| 53 | } |
| 54 | |
| 55 | return getDotPath(obj?.[key], nextPath, fallback) ?? fallback |
| 56 | } |
nothing calls this directly
no outgoing calls
no test coverage detected