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 "
-
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 ^0.0.0-2015-20-15.
-
gt(v1, v2): v1 > v2
-
gte(v1, v2): v1 >= v2
-
lt(v1, v2): v1 < v2
-
lte(v1, v2): v1 <= v2
-
eq(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
compare strings.
-
neq(v1, v2): v1 != v2 The opposite of eq.
-
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): Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if
v2 is greater. Sorts in ascending order if passed to Array.sort().
-
rcompare(v1, v2): The reverse of compare. Sorts an array of versions
in descending order when passed to Array.sort().
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.