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

Method expectKeyword

src/parser/indirect-object-parser.ts:237–250  ·  view source on GitHub ↗

* Expect and consume a keyword at current scanner position.

(keyword: string)

Source from the content-addressed store, hash-verified

235 * Expect and consume a keyword at current scanner position.
236 */
237 private expectKeyword(keyword: string): void {
238 // Skip any whitespace first
239 this.skipWhitespace();
240
241 for (let i = 0; i < keyword.length; i++) {
242 const byte = this.scanner.peek();
243
244 if (byte !== keyword.charCodeAt(i)) {
245 throw new ObjectParseError(`Expected keyword "${keyword}"`);
246 }
247
248 this.scanner.advance();
249 }
250 }
251
252 /**
253 * Skip whitespace characters.

Callers 2

parseObjectMethod · 0.95
readStreamMethod · 0.95

Calls 3

skipWhitespaceMethod · 0.95
advanceMethod · 0.80
peekMethod · 0.45

Tested by

no test coverage detected