MCPcopy Create free account
hub / github.com/LibPDF-js/core / parseInt

Method parseInt

src/fontbox/afm/parser.ts:562–581  ·  view source on GitHub ↗
(value: string, radix = 10)

Source from the content-addressed store, hash-verified

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());

Callers 9

parseCharMetricMethod · 0.95
parseCompositeMethod · 0.95
readIntMethod · 0.95
hexToBytesFunction · 0.80
hexToBytesFunction · 0.80
encodeDictRealMethod · 0.80
hexToStringMethod · 0.80
tryReadNumberMethod · 0.80
readStringMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected