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

Method isEndstreamAt

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

* Check whether the "endstream" keyword appears at the given position, * allowing optional whitespace before it.

(pos: number)

Source from the content-addressed store, hash-verified

204 * allowing optional whitespace before it.
205 */
206 private isEndstreamAt(pos: number): boolean {
207 const bytes = this.scanner.bytes;
208
209 if (pos > bytes.length) {
210 return false;
211 }
212
213 let i = pos;
214
215 while (i < bytes.length && isWhitespace(bytes[i])) {
216 i++;
217 }
218
219 const keyword = "endstream";
220
221 if (i + keyword.length > bytes.length) {
222 return false;
223 }
224
225 for (let j = 0; j < keyword.length; j++) {
226 if (bytes[i + j] !== keyword.charCodeAt(j)) {
227 return false;
228 }
229 }
230
231 return true;
232 }
233
234 /**
235 * Expect and consume a keyword at current scanner position.

Callers 1

readStreamMethod · 0.95

Calls 1

isWhitespaceFunction · 0.90

Tested by

no test coverage detected