数通智联化工云平台
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.
 
 
 
 
 

17 lines
527 B

function camelize(str) {
return str.replace(/-([a-z0-9])/g, (g) => g[1].toUpperCase());
}
function pascalize(str) {
const camel = camelize(str);
return camel.slice(0, 1).toUpperCase() + camel.slice(1);
}
function camelToKebab(key) {
const result = key.replace(/:/g, "-").replace(/([A-Z])/g, " $1").trim();
return result.split(/\s+/g).join("-").toLowerCase();
}
function snakelize(str) {
const kebab = camelToKebab(str);
return kebab.replace(/-/g, "_");
}
export { camelToKebab, camelize, pascalize, snakelize };