SemVer for 4D
Create an instance of SemVer to use it later.
$semver:=cs.SemVer.Instance.new()
$version:=$semver.version("1.2.3")
$version:=$semver.version("1.2") // 1.2.0
$version:=$semver.version(1;2;3)
$version:=$semver.version(New collection(1;2;3))
$version.major
$version.minor
$version.patch
You can extract specific digit without creating Version
object
$semver.major("1.2.3") // 1
$semver.minor("1.2.3") // 2
$semver.patch("1.2.3") // 3
But if you need to extract all the digits, prefer use
Version
object
$semver.valid("1.2.3") // True
$semver.valid("not.a.version") // False
$semver.compare(semver.v0; $semver.v1)
- return 0 if equals
- return 1 if first argument is greater
- return -1 if first argument is lower
semver.eq($semver.v1;"1.0.0")
$semver.gt($semver.v1; "0.9.0")
$semver.gt("0.9.2"; "0.9.0")
$semver.gt("1.0.0"; "0.9.0")
$semver.gte("1.5.6"; "0.9.0")
$semver.lt("0.5.6"; "0.9.0")
$semver.lte("0.5.6"; "0.9.0")
A range object contains two versions, the min
and the max
and allow to check if a version satisfy this bounds.
$range:=$semver.range(New collection("1.0.1"; "1.2.1"))
$range:=$semver.range(New object("min"; "1.0.1"; "max"; "1.2.1"))
$version:=$semver.range("1.2.3")
$version:=$semver.range($semver.version("1.2.3"))
min
andmax
will be equals
Use >, <, =, >= or <= for comparisons, or - to specify an inclusive range
examples:
>2.1
1.0.0 - 1.2.0
Use the tilde symbol, ~
examples:
~2.2.0
Use the caret (aka hat) symbol, ^
examples:
^2.2.1
^0.1.0
$valid:=semver.range(">1").satisfiedBy("1.5.1")
$valid:=semver.range("1.0.0 - 1.2.0").satisfiedBy("1.5.1")
$valid:=semver.range("^1.0.0").satisfiedBy("1.5.1")
- increment functions
- is valid function
- compare two versions
- check if version satisfy simple range
- compare version with special syntax like "<=2.5.0 || 5.0.0 - 7.2.3"
- support suffix(-prerelease and +build)
- support wildcards *,x,X
- support just two number with space and operators like ">= 1.2 < 3.0.0"
- clean version string (coerce)