@svizzle/utils/string-string

Methods

(static) capitalize() → {string}

Source:
Since:
  • 0.8.0

Capitalise the input string

Example
> capitalize('hello')
'Hello'
Parameters:
Type Description
string
Returns:
Type
string

(static) decapitalize() → {string}

Source:
Since:
  • 0.20.0

Decapitalise the input string (makes the first letter lowercase)

Example
> decapitalize('Hello')
'hello'
> decapitalize('HELLO')
'hELLO'
Parameters:
Type Description
string
Returns:
Type
string

(static) trimLastNewline(string) → {array}

Source:
Since:
  • 0.5.0

Trim the last char of the provided string if it's a newline

Example
> trimLastNewline('a\nb\nc')
'a\nb\nc'
> trimLastNewline('a\nb\nc\n')
'a\nb\nc'
> trimLastNewline('a\nb\nc\n\n')
'a\nb\nc\n'
> trimLastNewline('a\nb\nc\r\n')
'a\nb\nc'
> trimLastNewline('a\nb\nc\n\r\n')
'a\nb\nc\n'
Parameters:
Name Type Description
string string
Returns:
Type
array