(value: string, radix = 10)
| 560 | } |
| 561 | |
| 562 | private parseInt(value: string, radix = 10): number { |
| 563 | // Validate that the entire string is a valid integer |
| 564 | const trimmed = value.trim(); |
| 565 | |
| 566 | if (!/^-?\d+$/.test(trimmed) && radix === 10) { |
| 567 | throw new Error(`Error parsing AFM document: ${value}`); |
| 568 | } |
| 569 | |
| 570 | if (radix === 16 && !/^-?[0-9a-fA-F]+$/.test(trimmed)) { |
| 571 | throw new Error(`Error parsing AFM document: ${value}`); |
| 572 | } |
| 573 | |
| 574 | const result = Number.parseInt(trimmed, radix); |
| 575 | |
| 576 | if (Number.isNaN(result)) { |
| 577 | throw new Error(`Error parsing AFM document: ${value}`); |
| 578 | } |
| 579 | |
| 580 | return result; |
| 581 | } |
| 582 | |
| 583 | private readFloat(): number { |
| 584 | return this.parseFloat(this.readString()); |
no outgoing calls
no test coverage detected