string

Source:

Methods

(static) capitalizeFirstLetter(string) → {String}

Description:
  • Capitalize First Letter

Source:
Parameters:
Name Type Description
string String

String to capitolize

Returns:
Type
String

(static) extractMatchDetails(string, regex) → {Object|Null}

Description:
  • Function that matches regex against string and returns details helpful for replacing/using/highlighting a single match within a string

Source:
Parameters:
Name Type Description
string String

The string to extract from

regex Regex

The regular expression to match against

Returns:

If match return object with { matched, startIndex, endIndex, before, after }, when no match is found this return null

Type
Object | Null

(static) separateCssUnit(string) → {Object}

Description:
  • Will return an object with the separation details

Source:
Parameters:
Name Type Description
string String

CSS number with unit

Returns:

keys: value, original, unit

Type
Object

(static) stripTags(html)

Description:
  • Removes HTML tags from string (can be used in Node)

    • Different than DOM version
    • Note you can use document.createElement and grab textContent (but this could execute code in browser)
    • The method below will just use regex without creating Nodes
Source:
Parameters:
Name Type Description
html String

HTML string to find/replace

(static) titleCase(string, exceptions, defaults) → {String}

Description:
  • Convert string to title case

Source:
Parameters:
Name Type Description
string String

String to convert to title case

exceptions Array

Array of words that shouldn't be title case, common words are included by default

defaults Array

Default exceptions incase you want full control

Returns:
Type
String

(static) toInitials(string, short) → {String}

Description:
  • Converts a string to initials

    • Example "Jane Allen-Doe" --> "JAD"
    • Example (short) "Jane Allen-Doe" --> "JD"
    • Example "Wow this part-time" --> "WTPT"
    • Example "Wow There are 2 !! People." --> "WTA2P"
Source:
Parameters:
Name Type Description
string String

String to convert

short Boolean

If true the initials will be limited to two letters, unless it's only one word which would be single letter

Returns:
Type
String

(static) trimDoubleSpaces(string) → {String}

Description:
  • Remove double spaces

Source:
Parameters:
Name Type Description
string String

String to trim

Returns:
Type
String

(static) trimLineBreaks(string) → {String}

Description:
  • Remove line breaks

Source:
Parameters:
Name Type Description
string String

String to trim

Returns:
Type
String

(static) trimWhitespace(string) → {String}

Description:
  • Designed originally to flatten style definitions

Source:
Parameters:
Name Type Description
string String

String to trim

Returns:
Type
String

(static) truncate(string, max) → {string}

Description:
  • Truncates string with ellipsis if over the max, note use framework function if you need to know the effects of the truncate process (returns an object with info instead) this function only modifies the string

Source:
Parameters:
Name Type Description
string string

String to possibly truncate

max number

How many characters max?

Returns:
Type
string

(static) urlize(string) → {String}

Description:
  • Convert string to characters safe for URL

Source:
Parameters:
Name Type Description
string String

The string to convert

Returns:
Type
String