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'); |
| 8 | return forceCaps.includes(s.toUpperCase()) ? s.toUpperCase() : s[0].toUpperCase() + s.slice(1).toLowerCase(); |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 9 | } |
| 10 | |
| 11 | function keyValueList(data) { |
| 12 | let out = ""; |
| 13 | Object.entries(data).map(([key, value]) => { |
| 14 | out += `**${capitalize(key)}:** ${value}\n` |
| 15 | }) |
| 16 | return out; |
| 17 | } |
| 18 | |
| 19 | export default keyValueList; |