isSemVer
Test if a value is a semantic version string.
Usage
var isSemVer = require( '@stdlib/assert/is-semver' );
isSemVer( value )
Tests if a value
is a semantic version string.
var bool = isSemVer( '0.0.2' );
// returns true
bool = isSemVer( 'foo' );
// returns false
Examples
var isSemVer = require( '@stdlib/assert/is-semver' );
var bool = isSemVer( '1.0.0' );
// returns true
bool = isSemVer( '1.0.0-alpha.1' );
// returns true
bool = isSemVer( '0.1' );
// returns false
bool = isSemVer( null );
// returns false
CLI
Usage
Usage: is-semver [options] [<str>]
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 $'1.0.0\n0.3' | is-semver --split /\r?\n/ # Escaped... $ echo -n $'1.0.0\n0.3' | is-semver --split /\\r?\\n/
The implementation ignores trailing delimiters.
Examples
$ is-semver 0.1.0
true
$ is-semver 1.0
false
To use as a standard stream,
$ echo -n 0.2.1-beta.1 | is-semver
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 '1.0.0\t123' | is-semver --split '\t'
true
false