您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

kebabCase.js 659B

12345678910111213141516171819202122232425262728
  1. var createCompounder = require('./_createCompounder');
  2. /**
  3. * Converts `string` to
  4. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  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 kebab cased string.
  12. * @example
  13. *
  14. * _.kebabCase('Foo Bar');
  15. * // => 'foo-bar'
  16. *
  17. * _.kebabCase('fooBar');
  18. * // => 'foo-bar'
  19. *
  20. * _.kebabCase('__FOO_BAR__');
  21. * // => 'foo-bar'
  22. */
  23. var kebabCase = createCompounder(function(result, word, index) {
  24. return result + (index ? '-' : '') + word.toLowerCase();
  25. });
  26. module.exports = kebabCase;