* Recursively gets a value from a nested object using a key path array.
(obj: Record<string, unknown>, path: string[])
| 93 | * Recursively gets a value from a nested object using a key path array. |
| 94 | */ |
| 95 | function getNestedValue(obj: Record<string, unknown>, path: string[]): unknown { |
| 96 | const [first, ...rest] = path; |
| 97 | if (!first || !(first in obj)) { |
| 98 | return undefined; |
| 99 | } |
| 100 | const value = obj[first]; |
| 101 | if (rest.length === 0) { |
| 102 | return value; |
| 103 | } |
| 104 | if (value && typeof value === 'object' && value !== null) { |
| 105 | return getNestedValue(value as Record<string, unknown>, rest); |
| 106 | } |
| 107 | return undefined; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Get the effective value for a setting, considering inheritance from higher scopes |
no outgoing calls
no test coverage detected