I\'m looking for a JS method that will turn snake_case
into PascalCase
while keeping slashes intact.
// examples:
post -> Post
a
const snakeToCamel = str => str.replace( /([-_]\w)/g, g => g[ 1 ].toUpperCase() );
const snakeToPascal = str => {
let camelCase = snakeToCamel( str );
let pascalCase = camelCase[ 0 ].toUpperCase() + camelCase.substr( 1 );
return pascalCase;
}
console.log( snakeToPascal( "i_call_shop_session" ) );
Input : i_call_shop_session
Output : ICallShopSession