vuestic-ui
Version:
Vue 3 UI Framework
22 lines (21 loc) • 799 B
JavaScript
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
const wordsRegex = /[A-Z0-9]*(?:[^\-_|A-Z|\s.])*/gm;
const getWords = (str) => {
var _a;
return ((_a = str.match(wordsRegex)) == null ? void 0 : _a.map((word) => word.trim().split(/([0-9]+)|([a-zA-Z]+)/g)).flat().filter(Boolean)) || [];
};
const camelCaseToKebabCase = (str) => {
return getWords(str).map((word) => word.toLowerCase()).join("-");
};
const kebabCaseToCamelCase = (str) => {
return getWords(str).map((word, index) => index === 0 ? word.toLowerCase() : capitalize(word)).join("");
};
const startCase = (str) => {
return getWords(str).map(capitalize).join(" ");
};
export {
camelCaseToKebabCase as c,
kebabCaseToCamelCase as k,
startCase as s
};
//# sourceMappingURL=text-case.mjs.map