time-to-botec/squiggle/node_modules/@stdlib/assert/is-binary-string/README.md
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

2.2 KiB

isBinaryString

Test if a value is a binary string.

Usage

var isBinaryString = require( '@stdlib/assert/is-binary-string' );

isBinaryString( value )

Tests if a value is a binary string; i.e., a character sequence of 1's and 0's.

var bool = isBinaryString( '1000101' );
// returns true

bool = isBinaryString( 'beep' );
// returns false

bool = isBinaryString( '' );
// returns false

Examples

var isBinaryString = require( '@stdlib/assert/is-binary-string' );

var bool = isBinaryString( '1' );
// returns true

bool = isBinaryString( '0' );
// returns true

bool = isBinaryString( '101010101001' );
// returns true

bool = isBinaryString( '' );
// returns false

bool = isBinaryString( 'beep' );
// returns false

bool = isBinaryString( null );
// returns false

CLI

Usage

Usage: is-binary-string [options] [<string>]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.

Examples

$ is-binary-string 01234
false

To use as a standard stream,

$ echo -n '0110' | is-binary-string
true