blob: ecb9780959a00a88b3aca73cb41add6bfccbe6c0 [file] [log] [blame]
pineafan1dc15722022-03-14 21:27:34 +00001const forceCaps = [
2 "ID",
pineafan73a7c4a2022-07-24 10:38:04 +01003 "NSFW",
4 "URL"
pineafan63fc5e22022-08-04 22:04:10 +01005];
pineafan1dc15722022-03-14 21:27:34 +00006
7export function capitalize(s: string) {
pineafan63fc5e22022-08-04 22:04:10 +01008 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()
pineafan63fc5e22022-08-04 22:04:10 +010013 .replace("discord", "Discord");
pineafan73a7c4a2022-07-24 10:38:04 +010014 }).join(" ");
pineafan63fc5e22022-08-04 22:04:10 +010015 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]) => {
pineafan63fc5e22022-08-04 22:04:10 +010025 out += `**${capitalize(key)}:** ${value}\n`;
26 });
pineafan4f164f32022-02-26 22:07:12 +000027 return out;
28}
29
30export default keyValueList;