* Finds a dictionary that has the given key index in its NS.keys array
(objects: unknown[], keyIndex: number)
| 70 | * Finds a dictionary that has the given key index in its NS.keys array |
| 71 | */ |
| 72 | function findDictWithKey(objects: unknown[], keyIndex: number): ArchivedDict | undefined { |
| 73 | for (const obj of objects) { |
| 74 | if (typeof obj !== 'object' || obj === null) continue; |
| 75 | const dict = obj as ArchivedDict; |
| 76 | const keys = dict['NS.keys']; |
| 77 | if (!Array.isArray(keys)) continue; |
| 78 | |
| 79 | const hasKey = keys.some((k) => isUID(k) && k.UID === keyIndex); |
| 80 | if (hasKey) return dict; |
| 81 | } |
| 82 | return undefined; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Gets the value for a key in an NS.keys/NS.objects dictionary |
no test coverage detected