Multiple version scheme parser and comparitor
A versioning interpretter that can process multiple versioning schemes such as
Passes some 1290 tests (mostly from node-semver)
$ [sudo] npm install semvish
Borrows directly from
cleanprocess a SemVer-ish string to a SemVer compliant string
// => 1.2.0// => 1.2.0// => 1.2.0-beta1// => 1.2.0-beta1// => 1.2.0-alpha1// => 1.2.0-alpha1// => 1.0.0// => 1.0.0-rc1// => 1.0.0-rc1// => 0.0.0-alpha1// Handes prefixs and trims strings for all inputs (pretty much every stupid scheme I've ever seen)// => 1.2.0// => 1.2.0// => 1.2.0// => 1.2.0// => 1.2.0// => 1.2.0// => 1.2.0
valid is some string semverish?
satisfies(version, range, loose): whethere a given (SemVish) version matches a semver range - currently only supports semver ranges so
^2015-20-15 and similar will not work, instead use
v1 > v2
v1 >= v2
v1 < v2
v1 <= v2
v1 == v2 This is true if they're logically equivalent,
even if they're not the exact same string. You already know how to
v1 != v2 The opposite of
cmp(v1, comparator, v2): Pass in a comparison string, and it'll call
the corresponding function above.
"!==" do simple
string comparison, but are included for completeness. Throws if an
invalid comparison string is provided.
compare(v1, v2): Return
v1 == v2, or
v1 is greater, or
v2 is greater. Sorts in ascending order if passed to
rcompare(v1, v2): The reverse of compare. Sorts an array of versions
in descending order when passed to
Precedence for two pre-release versions with the same major, minor, and patch version MUST be determined by comparing each dot separated identifier from left to right until a difference is found as follows: identifiers consisting of only digits are compared numerically and identifiers with letters or hyphens are compared lexically in ASCII sort order.
Therefore as defined by
0.0.0-a100 < 0.0.0-a2. This minor rule limited us in the alternate supported versioning schemes so we forked the handling.