From 13e5974114f759bae73f3bfd68c62ce9cfaf785e Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 20 Feb 2022 21:38:14 -0600 Subject: add more stuff to profile and fix bugs --- src/lib/utils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/lib/utils.ts') diff --git a/src/lib/utils.ts b/src/lib/utils.ts index f16021d..197bf6b 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -26,7 +26,7 @@ const colorCodeCharacter = 'ยง' export function formattingCodeToHtml(formatted: string): string { let htmlOutput = '' // we store the hex code, not the formatting code - let currentColor = null + let currentColor: null | string = null // we store the css code, not the formatting code const activeSpecialCodes: string[] = [] function reset() { @@ -50,7 +50,7 @@ export function formattingCodeToHtml(formatted: string): string { // if there's already a color, close that tag if (currentColor) htmlOutput += '' currentColor = colorCodes[colorCharacter] - htmlOutput += `` + htmlOutput += `` } } else if (specialCodes[colorCharacter]) { if (!activeSpecialCodes.includes(specialCodes[colorCharacter])) { @@ -133,7 +133,7 @@ export function twemojiHtml(s: string) { const htmlEncoded = s.replace('<', '<').replace('>', '>').replace('&', '&') // replace unicode emojis with const asTwemoji = htmlEncoded.replace(emojiRegex, (match) => { - return `` + return `` }) return asTwemoji } @@ -150,5 +150,5 @@ export function formatNumber(n: number, digits = 3) { { value: 1e18, symbol: 'E' }, ] const item = numberSymbolsLookup.slice().reverse().find(item => n >= item.value) - return (n / item.value).toPrecision(digits).replace(/\.0+$|(\.[0-9]*[1-9])0+$/, '$1') + item.symbol + return (n / (item?.value ?? 1)).toPrecision(digits).replace(/\.0+$|(\.[0-9]*[1-9])0+$/, '$1') + (item?.symbol ?? '') } \ No newline at end of file -- cgit