SIGN IN SIGN UP

A modern JavaScript utility library delivering modularity, performance, & extras.

0 0 17 JavaScript
2016-03-26 00:00:01 -07:00
define(['./_createCompounder', './upperFirst'], function(createCompounder, upperFirst) {
2015-02-01 22:03:53 -08:00
/**
2016-03-26 00:00:01 -07:00
* Converts `string` to
* [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
2015-02-01 22:03:53 -08:00
*
* @static
* @memberOf _
2016-03-26 00:00:01 -07:00
* @since 3.1.0
2015-02-01 22:03:53 -08:00
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the start cased string.
* @example
*
2016-03-26 00:00:01 -07:00
* _.startCase('--foo-bar--');
2015-02-01 22:03:53 -08:00
* // => 'Foo Bar'
*
* _.startCase('fooBar');
* // => 'Foo Bar'
*
2016-03-26 00:00:01 -07:00
* _.startCase('__FOO_BAR__');
* // => 'FOO BAR'
2015-02-01 22:03:53 -08:00
*/
var startCase = createCompounder(function(result, word, index) {
2016-03-26 00:00:01 -07:00
return result + (index ? ' ' : '') + upperFirst(word);
2015-02-01 22:03:53 -08:00
});
return startCase;
});