blob: 54b8d99c4e5e0cb7dc7f420e7e1c0d229d6d2fc3 [file] [log] [blame]
const forceCaps = ["ID", "NSFW", "URL"];
export function capitalize(s: string) {
s = s.replace(/([A-Z])/g, " $1");
s = s
.split(" ")
.map((word) => {
return forceCaps.includes(word.toUpperCase())
? word.toUpperCase()
: (word[0] ?? "").toUpperCase() + word.slice(1).toLowerCase().replace("discord", "Discord");
})
.join(" ");
return s;
}
export function toCapitals(s: string) {
if (s.startsWith(undefined)) return "";
return s[0].toUpperCase() + s.slice(1).toLowerCase();
}
function keyValueList(data: Record<string, string>) {
let out = "";
Object.entries(data).map(([key, value]) => {
out += `**${capitalize(key)}:** ${value}\n`;
});
return out;
}
export default keyValueList;