String

Methods

capitaliseFirstLetter(loweropt) → {string}

Returns string with capitalised first letter
Parameters:
Name Type Attributes Default Description
lower boolean <optional>
false Flag if should lower all letters first
Returns:
string - New string

includes(search, startopt) → {boolean}

Polyfill for ECMAScript 2015 for String.prototype.includes
Parameters:
Name Type Attributes Default Description
search string Search for
start number <optional>
0 Searching start position
Returns:
boolean - Verdict

isLike(query) → {boolean}

Check if string is like given query (you can use regexp notation)
Parameters:
Name Type Description
query string Query
Returns:
boolean - Verdict

lowerFirstLetter() → {string}

Returns string with lower first letter
Returns:
string - New string

noCase() → {string}

Returns string with removed cases
Returns:
string - New string

reverse() → {string}

Returns reversed string
Returns:
string - Reversed string

toBoolean() → {boolean}

Returns string in boolean
Returns:
boolean - True if string looks somehow like 'true'

toCamelCase() → {string}

Returns string in camelCase
Returns:
string - String in camelCase

toChecksum() → {string}

Returns checksum crc32
Returns:
string - Checksum
Author:
  • joelpt
  • schnaader
See:

toKebabCase() → {string}

Returns string in kebab-case
Returns:
string - String in kebab-case

toPascalCase() → {string}

Returns string in PascalCase
Returns:
string - String in PascalCase

toSnakeCase(convertToUpperCaseopt) → {string}

Returns string in snake_case
Parameters:
Name Type Attributes Default Description
convertToUpperCase boolean <optional>
false Set this flag to convert to UpperCase
Returns:
string - String in snake_case

static editDistance(a, b) → {number}

Calculate edit distance between string a and b
Parameters:
Name Type Description
a string A
b string B
Returns:
number - Distance
See:

static getSimilarity(a, b) → {number}

Get similarity ratio based on edit distance
Parameters:
Name Type Description
a string A
b string B
Returns:
number - Ratio
See:

static isEmpty(sth) → {boolean}

Checks is given value is String and is empty
Parameters:
Name Type Description
sth string Something to check
Returns:
boolean - Verdict

static isInvalidOrEmpty(sth) → {boolean}

Checks is given value isn't a String or it is empty
Parameters:
Name Type Description
sth string Something to check
Returns:
boolean - Verdict

static isNotEmpty(sth) → {boolean}

Checks is given value is String and is not empty
Parameters:
Name Type Description
sth string Something to check
Returns:
boolean - Verdict