* get the code point that ends right before offset `offset`
(str: string, offset: number)
| 489 | * get the code point that ends right before offset `offset` |
| 490 | */ |
| 491 | function getPrevCodePoint(str: string, offset: number): number { |
| 492 | const charCode = str.charCodeAt(offset - 1); |
| 493 | if (isLowSurrogate(charCode) && offset > 1) { |
| 494 | const prevCharCode = str.charCodeAt(offset - 2); |
| 495 | if (isHighSurrogate(prevCharCode)) { |
| 496 | return computeCodePoint(prevCharCode, charCode); |
| 497 | } |
| 498 | } |
| 499 | return charCode; |
| 500 | } |
| 501 | |
| 502 | export function nextCharLength(str: string, offset: number): number { |
| 503 | const graphemeBreakTree = GraphemeBreakTree.getInstance(); |
no test coverage detected