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

Method parseValue

src/parser/object-parser.ts:113–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111 }
112
113 private parseValue(): ParseResult {
114 const token = this.buf1;
115
116 if (token === null) {
117 throw new ObjectParseError("Unexpected null token");
118 }
119
120 switch (token.type) {
121 case "keyword":
122 return this.parseKeyword(token.value);
123
124 case "number":
125 return this.parseNumberOrRef(token);
126
127 case "name":
128 this.shift();
129 return { object: PdfName.of(token.value), hasStream: false };
130
131 case "string":
132 this.shift();
133 return {
134 object: new PdfString(token.value, token.format),
135 hasStream: false,
136 };
137
138 case "delimiter":
139 return this.parseDelimiter(token.value);
140
141 default:
142 throw new ObjectParseError(`Unexpected token type: ${token.type}`);
143 }
144 }
145
146 private parseKeyword(value: string): ParseResult {
147 this.shift();

Callers 1

parseObjectMethod · 0.95

Calls 5

parseKeywordMethod · 0.95
parseNumberOrRefMethod · 0.95
shiftMethod · 0.95
parseDelimiterMethod · 0.95
ofMethod · 0.45

Tested by

no test coverage detected