isCapitalized

Test if a value is a string having an uppercase first character.

Usage

var isCapitalized = require( '@stdlib/assert/is-capitalized' );

isCapitalized( value )

Tests if a value is a string having an uppercase first character.

var bool = isCapitalized( 'Every noble work is at first impossible.' );
// returns true

bool = isCapitalized( 'HELLO WORLD!' );
// returns true

bool = isCapitalized( 'salt and light' );
// returns false

Notes

  • The function validates that a value is a string. For all other types, the function returns false.

Examples

var isCapitalized = require( '@stdlib/assert/is-capitalized' );

var bool = isCapitalized( 'Hello' );
// returns true

bool = isCapitalized( 'HELLO' );
// returns true

bool = isCapitalized( '' );
// returns false

bool = isCapitalized( 'hello' );
// returns false

CLI

Usage

Usage: is-capitalized [options] [<string>]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.
         --split sep           Delimiter for stdin data. Default: '/\\r?\\n/'.

Notes

  • If the split separator is a regular expression, ensure that the split option is either properly escaped or enclosed in quotes.

    # Not escaped...
    $ echo -n $'beEp booP\nFoo Bar' | is-capitalized --split /\r?\n/
    # Escaped...
    $ echo -n $'beEp booP\nFoo Bar' | is-capitalized --split /\\r?\\n/
    
  • The implementation ignores trailing delimiters.

Examples

$ is-capitalized Beep
true

To use as a standard stream,

$ echo -n 'boop' | is-capitalized
false

By default, when used as a standard stream, the implementation assumes newline-delimited data. To specify an alternative delimiter, set the split option.

$ echo -n 'beep\tFoo' | is-capitalized --split '\t'
false
true
Did you find this page helpful?