Semver Checker

Check which versions satisfy a range (^1.2.3, ~2.0, >=1 <3…), see what it means, then compare and sort versions as npm does

Like npm's --include-prerelease: without it, a pre-release only matches a range naming a pre-release of the same version.
Range syntax
^1.2.3
Compatible: >=1.2.3 <2.0.0-0. Below 1.0.0 the first non-zero number is the one held: ^0.2.3 is >=0.2.3 <0.3.0-0, ^0.0.3 is 0.0.3 only
~1.2.3
Patch updates: >=1.2.3 <1.3.0-0; ~1 is >=1.0.0 <2.0.0-0
1.2.x, 1.2, *
Any number where x, X or * stands, or where it is left out: >=1.2.0 <1.3.0-0
1.2.3 - 2.3
Inclusive: >=1.2.3 <2.4.0-0, a partial upper bound covering all its versions
>=1.2 <3
Comparators separated by spaces: a version must satisfy all of them
… || …
Either set: a version must satisfy one of them
The rules of npm's semver package, which Yarn and pnpm follow too. A -0 bound is the lowest pre-release of that version: <2.0.0-0 leaves out 2.0.0's pre-releases as well.