Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 1x 3x 3x | import { nonWhitespaceRegExp } from "@benneq/regexp";
/**
* Checks if a String contains only whitespace characters
*
* @example
* Returns `true` if the String is empty
* ```ts
* const result = isBlank("");
* console.log(result); // true
* ```
*
* @example
* Returns `true` if the String contains only whitespace characters
* ```ts
* const result = isBlank(" ");
* console.log(result); // true
* ```
*
* @example
* Returns `false` if the String contains any non-whitespace character
*
* ```ts
* const result = isBlank(" a ");
* console.log(result); // false
* ```
*
* @param str - the {@link String} to check
* @returns `true` if the String is empty or all characters are whitespace, otherwise `false`
*/
export const isBlank = (str: string): boolean => {
return !nonWhitespaceRegExp.test(str);
};
|