* Bump the parser to the target offset. * If target offset is beyond the end of the input, bump the parser to the end of the input.
(targetOffset: number)
| 1215 | * If target offset is beyond the end of the input, bump the parser to the end of the input. |
| 1216 | */ |
| 1217 | private bumpTo(targetOffset: number) { |
| 1218 | if (this.offset() > targetOffset) { |
| 1219 | throw Error( |
| 1220 | `targetOffset ${targetOffset} must be greater than or equal to the current offset ${this.offset()}` |
| 1221 | ) |
| 1222 | } |
| 1223 | |
| 1224 | targetOffset = Math.min(targetOffset, this.message.length) |
| 1225 | while (true) { |
| 1226 | const offset = this.offset() |
| 1227 | if (offset === targetOffset) { |
| 1228 | break |
| 1229 | } |
| 1230 | if (offset > targetOffset) { |
| 1231 | throw Error( |
| 1232 | `targetOffset ${targetOffset} is at invalid UTF-16 code unit boundary` |
| 1233 | ) |
| 1234 | } |
| 1235 | |
| 1236 | this.bump() |
| 1237 | if (this.isEOF()) { |
| 1238 | break |
| 1239 | } |
| 1240 | } |
| 1241 | } |
| 1242 | |
| 1243 | /** advance the parser through all whitespace to the next non-whitespace code unit. */ |
| 1244 | private bumpSpace() { |
no test coverage detected