Add capitalize

This commit is contained in:
MartinBraquet
2025-08-02 16:19:43 +02:00
parent 1270130b33
commit e6b9b3f9e0

12
lib/format.ts Normal file
View File

@@ -0,0 +1,12 @@
function capitalizeOne(str: string) {
if (!str) return "";
return str[0].toUpperCase() + str.slice(1).toLowerCase();
}
export function capitalize(str: string) {
return str
.split(" ")
.map(word => capitalizeOne(word))
.join(" ");
}