semver-extra
semver-extra
contains useful methods that aren't included in the vanilla semver package.
The main reason semver-extra
exists is to deal with pre-release versions.
Install
$ npm install semver-extra --save
Usage
var semver = ;
First of all, semver-extra
contains all methods of semver@4.x
, so we could use semver-extra
only without the vanilla one.
semver; // '>=1.2.3-0 <2.0.0-0'
semver.isStable(version)
semver; // -> truesemver; // -> falsesemver; // -> false
Checks whether the version
is a stable version.
semver.isPrerelease(version, [prerelease])
- version
string
- prerelease
String=
- If argument
prerelease
is not passed andversion
is an unstable version, it will returntrue
. - or
prerelease
could be the pre-release string.
- If argument
semver; // falsesemver; // truesemver; // falsesemver; // true, that supports numeric prerelease versionssemver; // true
Checks whether the version
is an unstable version or matches the prerelease
.
var versions = '1.1.2' '1.2.3-beta' '1.2.2' '1.2.1' '1.3.3' '1.5.0-rc';
semver.max(versions)
semver; // '1.5.0-rc'
Returns String
the maximun version in the list.
semver.maxStable(versions)
semver; // '1.3.3'
Returns String
the maximun stable version in the list.
semver.maxPrerelease(versions, [prerelease])
semver; // nullsemver; // '1.5.0-rc'semver; // '1.2.3-beta'
Returns the maximun (matched) pre-release version matches the prerelease.
License
MIT