* Check whether the "endstream" keyword appears at the given position, * allowing optional whitespace before it.
(pos: number)
| 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. |
no test coverage detected