@mintlify/common
Version:
Commonly shared code within Mintlify
9 lines (8 loc) • 368 B
JavaScript
export const camelToSentenceCase = (str) => {
// Split on capital letters and convert to lowercase
const words = str.split(/(?=[A-Z])/).map((word) => word.toLowerCase());
// Capitalize first word and join with spaces
return words
.map((word, index) => (index === 0 ? word.charAt(0).toUpperCase() + word.slice(1) : word))
.join(' ');
};