mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Bump to v3.0.0.
This commit is contained in:
28
string/kebabCase.js
Normal file
28
string/kebabCase.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import createCompounder from '../internal/createCompounder';
|
||||
|
||||
/**
|
||||
* Converts `string` to kebab case (a.k.a. spinal case).
|
||||
* See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Computers) for
|
||||
* more details.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to convert.
|
||||
* @returns {string} Returns the kebab cased string.
|
||||
* @example
|
||||
*
|
||||
* _.kebabCase('Foo Bar');
|
||||
* // => 'foo-bar'
|
||||
*
|
||||
* _.kebabCase('fooBar');
|
||||
* // => 'foo-bar'
|
||||
*
|
||||
* _.kebabCase('__foo_bar__');
|
||||
* // => 'foo-bar'
|
||||
*/
|
||||
var kebabCase = createCompounder(function(result, word, index) {
|
||||
return result + (index ? '-' : '') + word.toLowerCase();
|
||||
});
|
||||
|
||||
export default kebabCase;
|
||||
Reference in New Issue
Block a user