(count?: number)
| 259 | } |
| 260 | |
| 261 | private advance(count?: number): number { |
| 262 | let codeOrChar: number; |
| 263 | let newOffset: number; |
| 264 | let offsetAdvancedBy = 0; |
| 265 | |
| 266 | switch (count) { |
| 267 | case undefined: |
| 268 | case 1: |
| 269 | offsetAdvancedBy = this.#chSz; |
| 270 | this.#offset += this.#chSz; |
| 271 | this.#ch = this.#chNext; this.#chSz = this.#chNextSz; |
| 272 | this.#chNext = this.#chNextNext; this.#chNextSz = this.#chNextNextSz; |
| 273 | |
| 274 | newOffset = this.#offset + this.#chSz + this.#chNextSz; |
| 275 | codeOrChar = this.#text.charCodeAt(newOffset); |
| 276 | this.#chNextNext = (this.#chNextNextSz = sizeOf(codeOrChar)) === 1 ? codeOrChar : this.#text.codePointAt(newOffset)!; |
| 277 | return offsetAdvancedBy; |
| 278 | |
| 279 | case 2: |
| 280 | offsetAdvancedBy = this.#chSz + this.#chNextSz; |
| 281 | this.#offset += this.#chSz + this.#chNextSz; |
| 282 | this.#ch = this.#chNextNext; this.#chSz = this.#chNextNextSz; |
| 283 | |
| 284 | newOffset = this.#offset + this.#chSz; |
| 285 | codeOrChar = this.#text.charCodeAt(newOffset); |
| 286 | this.#chNext = (this.#chNextSz = sizeOf(codeOrChar)) === 1 ? codeOrChar : this.#text.codePointAt(newOffset)!; |
| 287 | |
| 288 | newOffset += this.#chNextSz; |
| 289 | codeOrChar = this.#text.charCodeAt(newOffset); |
| 290 | this.#chNextNext = (this.#chNextNextSz = sizeOf(codeOrChar)) === 1 ? codeOrChar : this.#text.codePointAt(newOffset)!; |
| 291 | return offsetAdvancedBy; |
| 292 | |
| 293 | default: |
| 294 | case 3: |
| 295 | offsetAdvancedBy = this.#chSz + this.#chNextSz + this.#chNextNextSz; |
| 296 | count -= 3; |
| 297 | while (count) { |
| 298 | // skip over characters while we work. |
| 299 | offsetAdvancedBy += sizeOf(this.#text.charCodeAt(this.#offset + offsetAdvancedBy)); |
| 300 | } |
| 301 | this.#offset += offsetAdvancedBy; |
| 302 | |
| 303 | // eslint-disable-next-line no-fallthrough |
| 304 | case 0: |
| 305 | newOffset = this.#offset; |
| 306 | codeOrChar = this.#text.charCodeAt(newOffset); |
| 307 | this.#ch = (this.#chSz = sizeOf(codeOrChar)) === 1 ? codeOrChar : this.#text.codePointAt(newOffset)!; |
| 308 | |
| 309 | newOffset += this.#chSz; |
| 310 | codeOrChar = this.#text.charCodeAt(newOffset); |
| 311 | this.#chNext = (this.#chNextSz = sizeOf(codeOrChar)) === 1 ? codeOrChar : this.#text.codePointAt(newOffset)!; |
| 312 | |
| 313 | newOffset += this.#chNextSz; |
| 314 | codeOrChar = this.#text.charCodeAt(newOffset); |
| 315 | this.#chNextNext = (this.#chNextNextSz = sizeOf(codeOrChar)) === 1 ? codeOrChar : this.#text.codePointAt(newOffset)!; |
| 316 | return offsetAdvancedBy; |
| 317 | } |
| 318 | } |
no test coverage detected