mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Bump to v3.0.0.
This commit is contained in:
27
string/snakeCase.js
Normal file
27
string/snakeCase.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import createCompounder from '../internal/createCompounder';
|
||||
|
||||
/**
|
||||
* Converts `string` to snake case.
|
||||
* See [Wikipedia](https://en.wikipedia.org/wiki/Snake_case) for more details.
|
||||
*
|
||||
* @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('--foo-bar');
|
||||
* // => 'foo_bar'
|
||||
*
|
||||
* _.snakeCase('fooBar');
|
||||
* // => 'foo_bar'
|
||||
*/
|
||||
var snakeCase = createCompounder(function(result, word, index) {
|
||||
return result + (index ? '_' : '') + word.toLowerCase();
|
||||
});
|
||||
|
||||
export default snakeCase;
|
||||
Reference in New Issue
Block a user