diff options
Diffstat (limited to 'deps/npm/node_modules/cli-table2/node_modules/lodash/string/snakeCase.js')
-rw-r--r-- | deps/npm/node_modules/cli-table2/node_modules/lodash/string/snakeCase.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/deps/npm/node_modules/cli-table2/node_modules/lodash/string/snakeCase.js b/deps/npm/node_modules/cli-table2/node_modules/lodash/string/snakeCase.js new file mode 100644 index 0000000000..c9ebffd913 --- /dev/null +++ b/deps/npm/node_modules/cli-table2/node_modules/lodash/string/snakeCase.js @@ -0,0 +1,26 @@ +var createCompounder = require('../internal/createCompounder'); + +/** + * Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case). + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the snake cased string. + * @example + * + * _.snakeCase('Foo Bar'); + * // => 'foo_bar' + * + * _.snakeCase('fooBar'); + * // => 'foo_bar' + * + * _.snakeCase('--foo-bar'); + * // => 'foo_bar' + */ +var snakeCase = createCompounder(function(result, word, index) { + return result + (index ? '_' : '') + word.toLowerCase(); +}); + +module.exports = snakeCase; |