You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
380 B
15 lines
380 B
// TODO: Same function is located in "/generators/block/index.cjs" file. Find a way to remove cjs files.
|
|
export function capitalize(str) {
|
|
if (typeof str !== 'string') {
|
|
return '';
|
|
}
|
|
|
|
return str
|
|
.toLowerCase()
|
|
.split(/[ -_]/g)
|
|
.filter((word) => !!word)
|
|
.map((word) => {
|
|
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
})
|
|
.join(' ');
|
|
}
|
|
|