Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / string / snakeCase.js
1 var 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  */
22 var snakeCase = createCompounder(function(result, word, index) {
23   return result + (index ? '_' : '') + word.toLowerCase();
24 });
25
26 module.exports = snakeCase;