datasquirel/package-shared/utils/slugToCamelTitle.js

24 lines
523 B
JavaScript
Raw Permalink Normal View History

2023-09-21 14:00:04 +00:00
// @ts-check
2024-10-14 06:49:01 +00:00
/**
*
* @param {string} text
* @returns
*/
2023-09-21 14:00:04 +00:00
module.exports = function slugToCamelTitle(text) {
if (text) {
let addArray = text.split("-").filter((item) => item !== "");
let camelArray = addArray.map((item) => {
2024-10-14 06:49:01 +00:00
return (
item.substr(0, 1).toUpperCase() + item.substr(1).toLowerCase()
);
2023-09-21 14:00:04 +00:00
});
let parsedAddress = camelArray.join(" ");
return parsedAddress;
} else {
return null;
}
};