* Deep copy any PDF object, remapping references to destination.
(obj: T)
| 137 | * Deep copy any PDF object, remapping references to destination. |
| 138 | */ |
| 139 | copyObject<T extends PdfObject>(obj: T): T { |
| 140 | if (obj instanceof PdfRef) { |
| 141 | // oxlint-disable-next-line typescript/no-unsafe-type-assertion |
| 142 | return this.copyRef(obj) as unknown as T; |
| 143 | } |
| 144 | |
| 145 | if (obj instanceof PdfStream) { |
| 146 | // oxlint-disable-next-line typescript/no-unsafe-type-assertion |
| 147 | return this.copyStream(obj) as unknown as T; |
| 148 | } |
| 149 | |
| 150 | if (obj instanceof PdfDict) { |
| 151 | // oxlint-disable-next-line typescript/no-unsafe-type-assertion |
| 152 | return this.copyDict(obj) as unknown as T; |
| 153 | } |
| 154 | |
| 155 | if (obj instanceof PdfArray) { |
| 156 | // oxlint-disable-next-line typescript/no-unsafe-type-assertion |
| 157 | return this.copyArray(obj) as unknown as T; |
| 158 | } |
| 159 | |
| 160 | // Primitives (PdfName, PdfNumber, PdfString, PdfBool, PdfNull) |
| 161 | // are immutable and can be reused directly |
| 162 | return obj; |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Copy a reference, creating the referenced object in dest if needed. |
no test coverage detected