'use strict';

// MODULES //

var isString = require( '@stdlib/utils/is-string' ).isPrimitive;


// MAIN //

/**
* Capitalize the first character in a string.
*
* @param {string} str - input string
* @throws {TypeError} str must be a string primitive
* @returns {string} capitalized string
*
* @example
* var out = capitalize( 'last man standing' );
* // returns  'Last man standing'
* @example
* var out = capitalize( 'presidential election' );
* // returns 'Presidential Election'
* @example
* var out = capitalize( 'javaScript' );
* // returns 'JavaScript'
* @example
* var out = capitalize( 'Hidden Treasures' );
* // returns 'Hidden Treasures';
*/
function capitalize( str ) {
	if ( !isString( str ) ) {
		throw new TypeError( 'invalid input argument. First argument must be a string primitive. Value: `' + str + '`.' );
	}
	if ( str === '' ) {
		return '';
	}
	return str.charAt( 0 ).toUpperCase() + str.slice( 1 );
} // end FUNCTION capitalize()


// EXPORTS //

module.exports = capitalize;

'use strict';

// MODULES //

var isString = require( '@stdlib/utils/is-string' ).isPrimitive;


// MAIN //

/**
* Capitalizes the first character in a string.
*
* @param {string} str - input string
* @throws {TypeError} str must be a string primitive
* @returns {string} capitalized string
*
* @example
* var out = capitalize( 'last man standing' );
* // returns  'Last man standing'
* @example
* var out = capitalize( 'presidential election' );
* // returns 'Presidential Election'
* @example
* var out = capitalize( 'javaScript' );
* // returns 'JavaScript'
* @example
* var out = capitalize( 'Hidden Treasures' );
* // returns 'Hidden Treasures';
*/
function capitalize( str ) {
	if ( !isString( str ) ) {
		throw new TypeError( 'invalid input argument. First argument must be a string primitive. Value: `' + str + '`.' );
	}
	if ( str === '' ) {
		return '';
	}
	return str.charAt( 0 ).toUpperCase() + str.slice( 1 );
} // end FUNCTION capitalize()


// EXPORTS //

module.exports = capitalize;

Update description