Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

snakeCase.js 638B

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