datasquirel/package-shared/utils/slugToCamelTitle.ts

21 lines
524 B
TypeScript
Raw Normal View History

2024-10-14 06:49:01 +00:00
/**
2025-01-10 19:10:28 +00:00
* # Slug to Camel case Title
2024-10-14 06:49:01 +00:00
*/
2025-01-10 19:10:28 +00:00
export default function slugToCamelTitle(text: String) {
2023-09-21 14:00:04 +00:00
if (text) {
let addArray = text.split("-").filter((item) => item !== "");
let camelArray = addArray.map((item) => {
2024-10-14 06:49:01 +00:00
return (
2025-01-10 19:10:28 +00:00
item.substring(0, 1).toUpperCase() +
item.substring(1).toLowerCase()
2024-10-14 06:49:01 +00:00
);
2023-09-21 14:00:04 +00:00
});
let parsedAddress = camelArray.join(" ");
return parsedAddress;
} else {
return null;
}
2025-01-10 19:10:28 +00:00
}