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

Method parseArray

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

Source from the content-addressed store, hash-verified

237 }
238
239 private parseArray(): ParseResult {
240 this.shift(); // consume '['
241
242 const items: PdfObject[] = [];
243
244 while (true) {
245 this.ensureBufferFilled();
246
247 if (this.buf1 === null || this.buf1.type === "eof") {
248 if (this.recoveryMode) {
249 this.warn("Unterminated array at EOF");
250 break;
251 }
252
253 throw new ObjectParseError("Unterminated array at EOF");
254 }
255
256 if (this.buf1.type === "delimiter" && this.buf1.value === "]") {
257 this.shift(); // consume ']'
258 break;
259 }
260
261 const result = this.parseObject();
262
263 if (result === null) {
264 if (this.recoveryMode) {
265 this.warn("Unexpected null in array");
266 break;
267 }
268
269 throw new ObjectParseError("Unexpected null in array");
270 }
271
272 items.push(result.object);
273 }
274
275 return { object: PdfArray.of(...items), hasStream: false };
276 }
277
278 private parseDict(): ParseResult {
279 this.shift(); // consume '<<'

Callers 1

parseDelimiterMethod · 0.95

Calls 6

shiftMethod · 0.95
ensureBufferFilledMethod · 0.95
warnMethod · 0.95
parseObjectMethod · 0.95
pushMethod · 0.80
ofMethod · 0.45

Tested by

no test coverage detected