pineafan | 1dc1572 | 2022-03-14 21:27:34 +0000 | [diff] [blame] | 1 | const forceCaps = [ |
| 2 | "ID", |
| 3 | "NSFW" |
| 4 | ] |
| 5 | |
| 6 | export function capitalize(s: string) { |
| 7 | s = s.replace(/([A-Z])/g, ' $1'); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 8 | return forceCaps.includes(s.toUpperCase()) ? s.toUpperCase() : s[0] |
| 9 | .toUpperCase() + s.slice(1) |
| 10 | .toLowerCase() |
| 11 | .replace("discord", "Discord"); |
| 12 | } |
| 13 | |
| 14 | export function toCapitals(s: string) { |
| 15 | return s[0].toUpperCase() + s.slice(1).toLowerCase(); |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | function keyValueList(data) { |
| 19 | let out = ""; |
| 20 | Object.entries(data).map(([key, value]) => { |
| 21 | out += `**${capitalize(key)}:** ${value}\n` |
| 22 | }) |
| 23 | return out; |
| 24 | } |
| 25 | |
| 26 | export default keyValueList; |