mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Add _.startCase.
This commit is contained in:
@@ -9451,6 +9451,31 @@
|
||||
return result + (index ? '-' : '') + word.toLowerCase();
|
||||
});
|
||||
|
||||
/**
|
||||
* Converts `string` to start case.
|
||||
* See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage)
|
||||
* for more details.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to convert.
|
||||
* @returns {string} Returns the start cased string.
|
||||
* @example
|
||||
*
|
||||
* _.startCase('Foo Bar');
|
||||
* // => 'Foo Bar'
|
||||
*
|
||||
* _.startCase('fooBar');
|
||||
* // => 'Foo Bar'
|
||||
*
|
||||
* _.startCase('__foo_bar__');
|
||||
* // => 'Foo Bar'
|
||||
*/
|
||||
var startCase = createCompounder(function(result, word, index) {
|
||||
return result + (index ? ' ' : '') + capitalize(word);
|
||||
});
|
||||
|
||||
/**
|
||||
* Pads `string` on the left and right sides if it is shorter then the given
|
||||
* padding length. The `chars` string may be truncated if the number of padding
|
||||
@@ -10747,6 +10772,7 @@
|
||||
lodash.some = some;
|
||||
lodash.sortedIndex = sortedIndex;
|
||||
lodash.sortedLastIndex = sortedLastIndex;
|
||||
lodash.startCase = startCase;
|
||||
lodash.startsWith = startsWith;
|
||||
lodash.template = template;
|
||||
lodash.trim = trim;
|
||||
|
||||
Reference in New Issue
Block a user