isASCII
Test whether a character belongs to the ASCII character set and whether this is true for all characters in a provided string.
Usage
var isASCII = require( '@stdlib/assert/is-ascii' );
isASCII( value )
Tests whether a character belongs to the ASCII character set and whether this is true for all characters in a provided string.
var bool = isASCII( 'beep' );
// returns true
Notes
- For non-string values, the function returns
false
.
Examples
var isASCII = require( '@stdlib/assert/is-ascii' );
var out = isASCII( 'beep' );
// returns true
out = isASCII( '' );
// returns false
out = isASCII( 'È' );
// returns false
out = isASCII( 123 );
// returns false
CLI
Usage
Usage: is-ascii [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
split
option is either properly escaped or enclosed in quotes.# Not escaped... $ echo -n $'beEp\n123' | is-ascii --split /\r?\n/ # Escaped... $ echo -n $'beEp\n123' | is-ascii --split /\\r?\\n/
The implementation ignores trailing delimiters.
Examples
$ is-ascii beep
true
To use as a standard stream,
$ echo -n 'beep' | is-ascii
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 'beep\t123' | is-ascii --split '\t'
true
false