A utility library with functions I'd rather not recreate if I can help it.
npm install alltheutilsAlltheutils
A utility library with functions I'd rather not recreate if I can help it.
_js
isWhitespace(" ") // true
isWhitespace("a") // false
`
$3
Click to go back to strings/text table of contents
Truncates all multiple-sequenced whitespace characters into a single space (U+0020) character. Whitespace characters are any character outlined on https://en.wikipedia.org/wiki/Whitespace_character.
#### Arguments:
| Name | Type | Description |
| ---- | ------ | ---------------------------------------- |
| str | string | The string to truncate whitespace within |
#### Example:
`js
truncateWhitespace(" ") // " "
truncateWhitespace(" a ") // " a "
truncateWhitespace("a a a") // "a a a"
truncateWhitespace("aaa") // "aaa"
``
Ā© Jacob Lockett 2025