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.
 
 
 
 

25 lines
742 B

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toUpperCamelCase = exports.toKebabCase = void 0;
const regex = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
/**
* Convert str to kebab-case
* @param str input string
* @returns output string
*/
function toKebabCase(str) {
return str.match(regex).join('-').toLowerCase();
}
exports.toKebabCase = toKebabCase;
/**
* Convert str to UpperCamelCase
* @param str import string
* @returns {string} output string
*/
function toUpperCamelCase(str) {
return str
.match(regex)
.map((x) => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase())
.join('');
}
exports.toUpperCamelCase = toUpperCamelCase;