(grapheme: string)
| 61 | } |
| 62 | |
| 63 | function graphemeWidth(grapheme: string): 1 | 2 { |
| 64 | if (hasMultipleCodepoints(grapheme)) return 2 |
| 65 | const codePoint = grapheme.codePointAt(0) |
| 66 | if (codePoint === undefined) return 1 |
| 67 | if (isEmoji(codePoint) || isEastAsianWide(codePoint)) return 2 |
| 68 | return 1 |
| 69 | } |
| 70 | |
| 71 | function* segmentGraphemes(str: string): Generator<Grapheme> { |
| 72 | for (const { segment } of getGraphemeSegmenter().segment(str)) { |
no test coverage detected