Files
lodash/camelCase.js
John-David Dalton 6cb3460fce Remove semicolons.
2017-02-05 22:22:04 -08:00

29 lines
738 B
JavaScript

import capitalize from './capitalize.js'
import createCompounder from './.internal/createCompounder.js'
/**
* Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
*
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the camel cased string.
* @see lowerCase, kebabCase, snakeCase, startCase, upperCase, upperFirst
* @example
*
* camelCase('Foo Bar')
* // => 'fooBar'
*
* camelCase('--foo-bar--')
* // => 'fooBar'
*
* camelCase('__FOO_BAR__')
* // => 'fooBar'
*/
const camelCase = createCompounder((result, word, index) => {
word = word.toLowerCase()
return result + (index ? capitalize(word) : word)
})
export default camelCase