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