# SemVer versions from components
smvr(4, 1:5)
# Parse SemVer versions from character
v <- parse_semver(c(
"1.0.0",
"1.0.0-alpha",
"1.0.0-beta",
"1.0.0-rc.2",
"1.0.0-rc.10",
NA
))
v
# Sorting
vctrs::vec_sort(v)
# Can be compared with string notation
v[v >= "1.0.0-rc.2" & !is.na(v)]
# Partial version components are treated as NA
suppressWarnings(parse_semver("1.5"))
# The numeric_version class supports versions with
# less than 3 components, and can be cast to smvr.
numeric_version("1.5") |>
vctrs::vec_cast(smvr())
# Be careful with hyphens in numeric_version and SemVer.
# The following examples yield opposite results.
numeric_version("1.0.0-1") > "1.0.0" # 1.0.0-1 is the same as 1.0.0.1
parse_semver("1.0.0-1") > "1.0.0" # 1.0.0-1 is a pre-release version
Run the code above in your browser using DataLab