blob: c9eb0c8e1e49a775828896c9a116bec0cf446e48 [file] [log] [blame]
pineafan1dc15722022-03-14 21:27:34 +00001const forceCaps = [
2 "ID",
3 "NSFW"
4]
5
6export function capitalize(s: string) {
7 s = s.replace(/([A-Z])/g, ' $1');
pineafan377794f2022-04-18 19:01:01 +01008 return forceCaps.includes(s.toUpperCase()) ? s.toUpperCase() : s[0]
9 .toUpperCase() + s.slice(1)
10 .toLowerCase()
11 .replace("discord", "Discord");
12}
13
14export function toCapitals(s: string) {
15 return s[0].toUpperCase() + s.slice(1).toLowerCase();
pineafan4f164f32022-02-26 22:07:12 +000016}
17
18function keyValueList(data) {
19 let out = "";
20 Object.entries(data).map(([key, value]) => {
21 out += `**${capitalize(key)}:** ${value}\n`
22 })
23 return out;
24}
25
26export default keyValueList;