blob: 1a76fa7cb807531f045c73e9548a1c949eaad11a [file] [log] [blame]
pineafan1dc15722022-03-14 21:27:34 +00001const forceCaps = [
2 "ID",
pineafan73a7c4a2022-07-24 10:38:04 +01003 "NSFW",
4 "URL"
pineafan1dc15722022-03-14 21:27:34 +00005]
6
7export function capitalize(s: string) {
8 s = s.replace(/([A-Z])/g, ' $1');
pineafan73a7c4a2022-07-24 10:38:04 +01009 s = s.split(" ").map(word => {
10 return forceCaps.includes(word.toUpperCase()) ? word.toUpperCase() : word[0]
11 .toUpperCase() + word.slice(1)
12 .toLowerCase()
13 .replace("discord", "Discord")
14 }).join(" ");
15 return s
pineafan377794f2022-04-18 19:01:01 +010016}
17
18export function toCapitals(s: string) {
19 return s[0].toUpperCase() + s.slice(1).toLowerCase();
pineafan4f164f32022-02-26 22:07:12 +000020}
21
22function keyValueList(data) {
23 let out = "";
24 Object.entries(data).map(([key, value]) => {
25 out += `**${capitalize(key)}:** ${value}\n`
26 })
27 return out;
28}
29
30export default keyValueList;