@stdlib/assert-is-binary-string
v0.2.2
Published
Test if a value is a binary string.
Downloads
19
Readme
isBinaryString
Test if a value is a binary string.
Installation
npm install @stdlib/assert-is-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
See Also
@stdlib/assert-is-binary-string-cli
: CLI package for use as a command-line utility.@stdlib/assert-is-string
: test if a value is a string.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.