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

Method expectKeyword

src/parser/xref-parser.ts:592–602  ·  view source on GitHub ↗

* Expect and consume a keyword at current position.

(keyword: string)

Source from the content-addressed store, hash-verified

590 * Expect and consume a keyword at current position.
591 */
592 private expectKeyword(keyword: string): void {
593 for (let i = 0; i < keyword.length; i++) {
594 const byte = this.scanner.peek();
595
596 if (byte !== keyword.charCodeAt(i)) {
597 throw new XRefParseError(`Expected keyword "${keyword}"`);
598 }
599
600 this.scanner.advance();
601 }
602 }
603
604 /**
605 * Check if current position starts with a keyword (without consuming).

Callers 1

parseTableMethod · 0.95

Calls 2

advanceMethod · 0.80
peekMethod · 0.45

Tested by

no test coverage detected