semvish v1.1.0
SemVish

A versioning interpretter that can process multiple versioning schemes such as
- SemVer
<Max>-<Min><Max>-<Min>-<release><Max><Max>-<release><release>
Passes some 1290 tests (mostly from node-semver)
Install
$ [sudo] npm install semvishMotivation
jsDelivr needed a multi version comparitor scheme
API
Borrows directly from node-semver's API
cleanprocess a SemVer-ish string to a SemVer compliant string
clean("1.2") // => 1.2.0
clean("1.2.0") // => 1.2.0
clean("1.2.0-beta1") // => 1.2.0-beta1
clean("1.2.0beta1") // => 1.2.0-beta1
clean("1.2-alpha1") // => 1.2.0-alpha1
clean("1.2alpha1") // => 1.2.0-alpha1
clean("1") // => 1.0.0
clean("1-rc1") // => 1.0.0-rc1
clean("1rc1") // => 1.0.0-rc1
clean("alpha1") // => 0.0.0-alpha1
// Handes prefixs and trims strings for all inputs (pretty much every stupid scheme I've ever seen)
clean("v-1.2.0 ") // => 1.2.0
clean(" v1.2 ") // => 1.2.0
clean("==v==1.2") // => 1.2.0
clean("_v--1.2.0") // => 1.2.0
clean("V1.2") // => 1.2.0
clean("-VERSION-1.2 ") // => 1.2.0
clean("v.1.2") // => 1.2.0validis some string semverish?satisfies(version, range, loose): whethere a given (SemVish) version matches a semver range - currently only supports semver ranges so^2015-20-15and similar will not work, instead use^0.0.0-2015-20-15.gt(v1, v2):v1 > v2gte(v1, v2):v1 >= v2lt(v1, v2):v1 < v2lte(v1, v2):v1 <= v2eq(v1, v2):v1 == v2This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings.neq(v1, v2):v1 != v2The opposite ofeq.cmp(v1, comparator, v2): Pass in a comparison string, and it'll call the corresponding function above."==="and"!=="do simple string comparison, but are included for completeness. Throws if an invalid comparison string is provided.compare(v1, v2): Return0ifv1 == v2, or1ifv1is greater, or-1ifv2is greater. Sorts in ascending order if passed toArray.sort().rcompare(v1, v2): The reverse of compare. Sorts an array of versions in descending order when passed toArray.sort().
Differences from semver spec
- Minorly divergent (see #1) in the way pre-releases are handled: prereleases are compared naturally while the semver spec states that
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 Semver: 0.0.0-a100 < 0.0.0-a2. This minor rule limited us in the alternate supported versioning schemes so we forked the handling.