isBlankString
Test if a value is a blank string.
Usage
var isBlankString = require( '@stdlib/assert/is-blank-string' );
isBlankString( value )
Tests if a value is a blank string (i.e., an empty string or a string consisting only of whitespace characters).
var bool = isBlankString( ' ' ); // returns true bool = isBlankString( '' ); // returns true bool = isBlankString( 0 ); // returns false
Examples
var isBlankString = require( '@stdlib/assert/is-blank-string' ); var out = isBlankString( ' ' ); // returns true out = isBlankString( '\t\t\t' ); // returns true out = isBlankString( '\r\n' ); // returns true out = isBlankString( '' ); // returns true out = isBlankString( 'beep boop' ); // returns false out = isBlankString( null ); // returns false
CLI
Usage
Usage: is-blank-string [options] [<string>]
Options:
-h, --help Print this message.
-V, --version Print the package version.
--split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
Notes
-
If the split separator is a regular expression, ensure that the
splitoption is either properly escaped or enclosed in quotes.# Not escaped... $ echo -n $'\nisMobile' | is-blank-string --split /\r?\n/ # Escaped... $ echo -n $'\nisMobile' | is-blank-string --split /\\r?\\n/
-
The implementation ignores trailing delimiters.
Examples
$ is-blank-string baz
falseTo use as a standard stream,
$ echo -n ' \t ' | is-blank-string true
By default, when used as a standard stream, the implementation assumes newline-delimited data. To specify an alternative delimiter, set the split option.
$ echo -n '\t123' | is-blank-string --split '\t' true false
See Also
@stdlib/assert/is-string: test if a value is a string.@stdlib/assert/is-empty-string: test if a value is an empty string.