first version string
second version string
Optional
optionsOrLoose: boolean | Optionsan options object { loose }
(where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
0
if v1
== v2
-1
if v1
> v2
1
if v1
< v2
The reverse of compare.
Remarks
versionArray.sort(rcompare)
can sort in descending order forMAJOR.MINOR.PATCH[-PRERELEASE]
, excluding build identifier ([+BUILD]
). This is different fromrsort()
, which also sorts in descending order but for the wholeMAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]
Example