isDigitString

Test whether a string contains only numeric digits.

Usage

var isDigitString = require( '@stdlib/assert/is-digit-string' );

isDigitString( value )

Tests whether a string contains only numeric digits.

var bool = isDigitString( '0123456789' );
// returns true

Notes

  • For non-string values, the function returns false.

Examples

var isDigitString = require( '@stdlib/assert/is-digit-string' );

var out = isDigitString( '0123456789' );
// returns true

out = isDigitString( '' );
// returns false

out = isDigitString( '0xffffff' );
// returns false

out = isDigitString( 123 );
// returns false

CLI

Usage

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

Options:

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

Examples

$ is-digit-string 0123456789
true

To use as a standard stream,

$ echo -n '0123456789' | is-digit-string
true