``` ~/go/bin/sourcemapper -output ddb -jsurl https://media.dndbeyond.com/character-app/static/js/main.90aa78c5.js ```
16 lines
445 B
TypeScript
16 lines
445 B
TypeScript
/**
|
|
* Converts a string from other cases to camelCase
|
|
* @param string the value to camelCase
|
|
* @example
|
|
* camelCase('foo-bar') // 'fooBar'
|
|
*/
|
|
export const camelCase = (string: string) => string
|
|
.replace(/([A-Z])([A-Z])/g, '$1 $2')
|
|
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
.replace(/[^a-zA-Z\u00C0-\u00ff]/g, ' ')
|
|
.toLowerCase()
|
|
.split(' ')
|
|
.filter(value => value)
|
|
.map((s, i) => (i > 0 ? s[0].toUpperCase() + s.slice(1) : s))
|
|
.join('')
|