0
1
Fork 0
hedera-web-mindshore/js/vn/string-util.js

28 lines
736 B
JavaScript
Raw Normal View History

2022-05-24 21:11:12 +00:00
module.exports = {
kebabToCamel: kebabToCamel,
kebabToPascal: kebabToPascal
};
/**
* Converts a kebab-case (hyphenized) string to camelCase (lowerCamelCase).
*
* @param {String} string The kebab-case string
* @return {String} The string parsed to camelCase
*/
function kebabToCamel(string) {
function replaceFunc(token) {
return token.charAt(1).toUpperCase();
}
return string.replace(/-./g, replaceFunc);
}
/**
* Converts a kebab-case (hyphenized) string to PascalCase (UpperCamelCase).
*
* @param {String} string The kebab-case string
* @return {String} The string parsed to PascalCase
*/
function kebabToPascal(string) {
string = string.charAt(0).toUpperCase() + string.substr(1);
return kebabToCamel(string);
}