Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 34x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { lowerFirst } from './lowerFirst'
import { splitByCase } from './splitByCase'
import { upperFirst } from './upperFirst'
/**
* format string to camel case
*
* @param text string to format
* @returns camel case string
*
* {@link https://lodash.com/docs#camelCase}
*/
export function camelCase(text: string) {
return lowerFirst(splitByCase(text).map(word => upperFirst(word.toLowerCase())).join(''))
}
if (import.meta.vitest) {
const { test, expect } = import.meta.vitest
test('camelCase', () => {
expect(camelCase('useXx')).toBe('useXx')
expect(camelCase('usexx')).toBe('usexx')
expect(camelCase('use-xx')).toBe('useXx')
expect(camelCase('use xx')).toBe('useXx')
expect(camelCase('UseXx')).toBe('useXx')
expect(camelCase('use_xx')).toBe('useXx')
expect(camelCase('Use Xx')).toBe('useXx')
expect(camelCase('Use-Xx')).toBe('useXx')
expect(camelCase('USE XX')).toBe('useXx')
})
}
|