(value: unknown, keys: Array<string>)
| 80 | } |
| 81 | |
| 82 | export function getMapValue(value: unknown, keys: Array<string>): unknown { |
| 83 | const object = mapLikeToObject(value); |
| 84 | |
| 85 | for (const key of keys) { |
| 86 | if (Object.hasOwn(object, key)) { |
| 87 | return object[key]; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | const lowerCaseKeyToOriginal = new Map<string, string>(); |
| 92 | for (const key of Object.keys(object)) { |
| 93 | const lowerCaseKey = key.toLowerCase(); |
| 94 | if (!lowerCaseKeyToOriginal.has(lowerCaseKey)) { |
| 95 | lowerCaseKeyToOriginal.set(lowerCaseKey, key); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | for (const key of keys) { |
| 100 | const original = lowerCaseKeyToOriginal.get(key.toLowerCase()); |
| 101 | if (original !== undefined) { |
| 102 | return object[original]; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | return undefined; |
| 107 | } |
no test coverage detected