MCPcopy Create free account
hub / github.com/TanStack/ai / displayWidth

Function displayWidth

packages/ai-code-mode-skills/test-cli/cli.ts:55–60  ·  view source on GitHub ↗

* Get the display width of a string, accounting for emojis

(str: string)

Source from the content-addressed store, hash-verified

53 * Get the display width of a string, accounting for emojis
54 */
55function displayWidth(str: string): number {
56 const emojiRegex =
57 /[\u{1F300}-\u{1F9FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|✅|❌|⚠️/gu
58 const emojiCount = (str.match(emojiRegex) || []).length
59 return str.length + emojiCount
60}
61
62/**
63 * Pad a string to a display width, accounting for emojis

Callers 2

padEndFunction · 0.85
formatGridFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected