(container: Record<string, unknown>, compositeKey: string)
| 10 | * @return value in the final key of the nested container, or `undefined` |
| 11 | */ |
| 12 | export function get(container: Record<string, unknown>, compositeKey: string): unknown { |
| 13 | // Split the key into subkeys |
| 14 | const keyList = getKeys(compositeKey); |
| 15 | // Recursively get the value of each key; |
| 16 | let value: Record<string, unknown> | unknown = container; |
| 17 | for (const key of keyList) { |
| 18 | // If any intermediate subfield is not an object, return undefined |
| 19 | value = isObject(value) ? value[key] : undefined; |
| 20 | } |
| 21 | return value; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Checks if argument is an "indexable" object (not a primitive value, nor null) |
no test coverage detected