Create a vector of pre-release identifiers, which can be used for marking versions as pre-release versions.
pre_release_ids()
is a low-level constructor for creating pre-release identifiers from individual components.parse_pre_release_ids()
parses a character vector into pre-release identifiers.
Empty identifiers are special cases that indicate not a pre-release version.
Usage
new_pre_release_ids(id1 = character(), id2 = "", id3 = "", id4 = "", id5 = "")
parse_pre_release_ids(x)
Arguments
- id1, id2, id3, id4, id5
Single pre-release identifiers. Each identifier can be something to be cast to a pre_release_identifier vector by
vctrs::vec_cast()
.- x
A character vector representing pre-release identifiers. Each identifier separated by a dot (
"."
) will be parsed as a pre_release_identifier.
Details
Internally, pre_release_ids store up to 5 pre_release_identifier.
So this can't represent pre-release identifiers with more than 5 components.
If passing character containing more than 5 components to
parse_pre_release_ids()
, it will throw an error.
Examples
# Each components are concatenated with a dot
new_pre_release_ids("rc", 1:3)
#> rc.1
#> rc.2
#> rc.3
ids <- parse_pre_release_ids(
c("", "alpha.beta", "alpha.1", "beta", "beta.11", "beta.2")
)
ids
#> <empty>
#> alpha.beta
#> alpha.1
#> beta
#> beta.11
#> beta.2
# Empty ids have the highest precedence
# (Used to indicate not a pre-release version)
vctrs::vec_sort(ids)
#> alpha.1
#> alpha.beta
#> beta
#> beta.2
#> beta.11
#> <empty>
# Works with base R vectors.
ids[ids > "beta.2"]
#> <empty>
#> beta.11