Add _.startCase.

This commit is contained in:
James Kyle
2015-01-31 15:09:31 -08:00
committed by jdalton
parent 4e3a72388d
commit 849fd71f76
2 changed files with 42 additions and 5 deletions

View File

@@ -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;