* Get inheritable number value from field hierarchy.
(dict: PdfDict, key: string, registry: ObjectRegistry)
| 103 | * Get inheritable number value from field hierarchy. |
| 104 | */ |
| 105 | function getInheritableFieldNumber(dict: PdfDict, key: string, registry: ObjectRegistry): number { |
| 106 | let current: PdfDict | null = dict; |
| 107 | const visited = new Set<PdfDict>(); |
| 108 | const resolve = registry.resolve.bind(registry); |
| 109 | |
| 110 | while (current) { |
| 111 | if (visited.has(current)) { |
| 112 | break; |
| 113 | } |
| 114 | |
| 115 | visited.add(current); |
| 116 | |
| 117 | const value = current.getNumber(key, resolve); |
| 118 | |
| 119 | if (value) { |
| 120 | return value.value; |
| 121 | } |
| 122 | |
| 123 | const parent = current.getDict("Parent", resolve); |
| 124 | |
| 125 | if (!parent) { |
| 126 | break; |
| 127 | } |
| 128 | |
| 129 | current = parent; |
| 130 | } |
| 131 | |
| 132 | return 0; |
| 133 | } |
no test coverage detected