* Get the display width of a string, accounting for emojis
(str: string)
| 53 | * Get the display width of a string, accounting for emojis |
| 54 | */ |
| 55 | function 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 |
no outgoing calls
no test coverage detected