Skip to main content

String Methods

camelCase

Converts string to camel case. https://developer.mozilla.org/en-US/docs/Glossary/Camel_case

Since: 0.1.0

Arguments

ParamTypeDescription
strstringThe string to convert.

Returns

TypeDescription
stringReturns the camel cased string.

Declaration

declare function camelCase(str?: string): string;

Examples

camelCase('foo bar'); // 'fooBar'
camelCase('foo-bar'); // 'fooBar'
camelCase('FOO__bar'); // 'fooBar'

capitalize

Converts the first character of string to upper case and the remaining to lower case

Since: 0.1.0

Arguments

ParamTypeDescription
strstringThe string to capitalize

Returns

TypeDescription
stringRetruns the capitalized string

Declaration

declare const capitalize: (str: string) => string;

Examples

capitalize('HELLO'); // 'Hello'

kebabCase

Convert string to kebab case. https://developer.mozilla.org/en-US/docs/Glossary/Kebab_case

Since: 0.1.0

Arguments

ParamTypeDescription
strstringThe string to convert.

Returns

TypeDescription
stringReturns the kebab cased string.

Declaration

declare function kebabCase(str: string): string;

Examples

kebabCase('foo bar'); // 'foo-bar'
kebabCase('foo-bar'); // 'foo-bar'
kebabCase('FOO__ bar'); // 'foo-bar'

pascalCase

Convert string to camel case, but the first character of string to upper case

Since: 0.1.0

Arguments

ParamTypeDescription
strstringThe string to convert.

Returns

TypeDescription
stringReturns the pascal cased string.

Declaration

declare function pascalCase(str: string): string;

Examples

camelCase('foo bar'); // 'FooBar'
camelCase('foo-bar'); // 'FooBar'
camelCase('FOO__bar'); // 'FooBar'

snakeCase

Convert string to snake case. https://developer.mozilla.org/en-US/docs/Glossary/Snake_case

Since: 0.1.0

Arguments

ParamTypeDescription
strstringThe string to convert.

Returns

TypeDescription
stringReturns the snake cased string.

Declaration

declare function snakeCase(str: string): string;

Examples

snakeCase('foo bar'); // 'foo_bar'
snakeCase('foo-bar'); // 'foo_bar'
snakeCase('FOO__ bar'); // 'foo_bar'