MCPcopy Create free account
hub / github.com/Noumena-Network/code / graphemeWidth

Function graphemeWidth

src/ink/termio/parser.ts:63–69  ·  view source on GitHub ↗
(grapheme: string)

Source from the content-addressed store, hash-verified

61}
62
63function 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
71function* segmentGraphemes(str: string): Generator<Grapheme> {
72 // Terminal C0 line controls must remain individual actions even when the

Callers 1

Calls 3

hasMultipleCodepointsFunction · 0.85
isEmojiFunction · 0.85
isEastAsianWideFunction · 0.85

Tested by

no test coverage detected