1 export function toCamelCase(str: string): string {
2 return /^([a-zA-Z][a-zA-Z0-9]*)(([A-Z][a-z0-9]+)+)$/.test(str)
3 ? str
4 : str
5 .toLowerCase()
6 .replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase())
7 }