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.

29 line
701 B

4 年之前
  1. var capitalize = require('./capitalize'),
  2. createCompounder = require('./_createCompounder');
  3. /**
  4. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  5. *
  6. * @static
  7. * @memberOf _
  8. * @since 3.0.0
  9. * @category String
  10. * @param {string} [string=''] The string to convert.
  11. * @returns {string} Returns the camel cased string.
  12. * @example
  13. *
  14. * _.camelCase('Foo Bar');
  15. * // => 'fooBar'
  16. *
  17. * _.camelCase('--foo-bar--');
  18. * // => 'fooBar'
  19. *
  20. * _.camelCase('__FOO_BAR__');
  21. * // => 'fooBar'
  22. */
  23. var camelCase = createCompounder(function(result, word, index) {
  24. word = word.toLowerCase();
  25. return result + (index ? capitalize(word) : word);
  26. });
  27. module.exports = camelCase;