Сниппет underscore_case в camelCase
function underscoreToCamelCase(valueStr) {
return (valueStr).replace(/_([a-z])/g, (m, w) => w.toUpperCase());
}
underscoreToCamelCase('some_text'); // "someText"
Сниппет camelCase в dash-case
function camelCaseToDash(str) {
return str.replace(/([A-Z])/g, ($1) => {
return '-' + $1.toLowerCase();
});
}
// example
camelCaseToDash('someText'); // "some-text"