String Helpers
Utility functions for working with string operations.
Functions
Section titled “Functions”| Function | Description |
|---|---|
camelCase | Converts a string to camelCase. |
capitalize | Capitalizes the first letter of a string. |
dedent | Strips the common leading whitespace from every line of a multi-line string, and trims a single leading/trailing blan… |
escapeHtml | Escapes the HTML special characters `&`, `<`, `>`, `”`, and `’` in a string. |
escapeRegExp | Escapes regular expression metacharacters (`. |
extractErrorMessage | Convert an error to a readable message. |
formatProgressBar | Formats a value as a text progress bar, repeating `filledChar`/`emptyChar` across `width` cells proportional to `valu… |
injectWordBreaks | Adds word-break opportunities to a string so it can wrap cleanly in narrow UI containers such as side panels or table… |
isBlank | Checks if a string is blank — empty or contains only whitespace characters. |
isEmpty | Checks if a string is empty (`""`), `null`, or `undefined`. |
isNonEmpty | Checks if a string is non-empty (has at least one character). |
isNotBlank | Checks if a string is not blank — non-empty and contains at least one non-whitespace character. |
kebabCase | Converts a string to kebab-case. |
leadingSentence | Extracts the leading sentence from a string. |
padStart / padEnd | native JS String.prototype.padStart() / padEnd() (ES2017) |
pascalCase | Converts a string to PascalCase. |
removeDiacritics | Removes diacritical marks (accents) from a string, e.g. |
repeat | native JS String.prototype.repeat() (ES2015) |
slugify | Converts a string into a URL-friendly slug. |
snakeCase | Converts a string to snake_case. |
startsWith / endsWith | native JS String.prototype.startsWith() / endsWith() (ES2015) |
template | Interpolates `{{key}}` placeholders in a template string with values from a data record. |
titleCase | Converts a string to Title Case. |
trim / trimStart / trimEnd | native JS String.prototype.trim() / trimStart() / trimEnd() (ES2019) |
truncate | Truncates a string to `maxLength` characters, appending an ellipsis when cut. |
unescapeHtml | Unescapes the HTML entities `&`, `<`, `>`, `”`, and `'` back to `&`, `<`, `>`, `”`, and `’`. |
words | Splits a string into an array of words. |