pascalcase
Convert a string to Pascal case.
Usage
var pascalcase = require( '@stdlib/string/pascalcase' );
pascalcase( str )
Converts a string to Pascal case.
var out = pascalcase( 'foo bar' );
// returns 'FooBar'
out = pascalcase( 'IS_MOBILE' );
// returns 'IsMobile'
out = pascalcase( 'Hello World!' );
// returns 'HelloWorld'
out = pascalcase( '--foo-bar--' );
// returns 'FooBar'
Examples
var pascalcase = require( '@stdlib/string/pascalcase' );
var str = 'Hello World!';
var out = pascalcase( str );
// returns 'HelloWorld'
str = 'HELLO WORLD!';
out = pascalcase( str );
// returns 'HelloWorld'
str = 'To be, or not to be: that is the question.';
out = pascalcase( str );
// returns 'ToBeOrNotToBeThatIsTheQuestion'
CLI
Usage
Usage: pascalcase [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\nisMobile' | pascalcase --split /\r?\n/ # Escaped... $ echo -n $'beEp booP\nisMobile' | pascalcase --split /\\r?\\n/
The implementation ignores trailing delimiters.
Examples
$ pascalcase 'hello world!'
HelloWorld
To use as a standard stream,
$ echo -n 'beEp booP' | pascalcase
BeEpBooP
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_boop\tisMobile' | pascalcase --split '\t'
BeepBoop
IsMobile