hedera-web/js/vn/string-util.js

34 lines
749 B
JavaScript

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);
}