const splittersAndLower = /[-./_]+[a-z]/g; /** @public */ export function camelCase(str: string) { return str .replace(splittersAndLower, (s) => { return s[1]?.toUpperCase(); }) .replace(spliters, ''); } /** * Uppercase first char * @public */ export function ucfirst(str: T): Capitalize { if (!str) return str as any; return (str[0].toUpperCase() + str.slice(1)); } /** * lowercase first char * @public */ export function lcfirst(str: T): Uncapitalize { if (!str) return str as any; return (str[0].toLowerCase() + str.slice(1)); } const prefixCapitals = /^[A-Z]+/; const allCapitals = /[A-Z]+/g; const spliters = /[-./_]+/g; /** @public */ export function linux_case(str: string) { return str .replace(prefixCapitals, (s) => { return s.toLowerCase(); }) .replace(allCapitals, (s) => { return `_${s.toLowerCase()}`; }) .replace(spliters, '_'); } /** @public */ export function linux_case_hyphen(str: string) { return str .replace(prefixCapitals, (s) => { return s.toLowerCase(); }) .replace(allCapitals, (s) => { return `-${s.toLowerCase()}`; }) .replace(spliters, '-'); }