pre_release_identifier {smvr} | R Documentation |
Single pre-release identifier
Description
A class representing a single pre-release identifier (alphanumeric or numeric) for Semantic Versioning 2.0.0.
Usage
new_pre_release_identifier(x = character())
Arguments
x |
Something that can be coerced to a character vector by
|
Details
Identifiers are compared based on the following criteria:
If the identifier is empty, it is treated as the smallest value.
Integers greater than or equal to 0 are treated as numeric identifiers and compared numerically.
Else, identifiers are treated as alphanumeric identifiers and compared lexically ASCII sort order.
Numeric identifiers always have lower precedence than alphanumeric identifiers.
Value
A pre_release_identifier vector.
See Also
-
pre_release_ids: Whole pre-release identifiers (Concatenation of pre_release_identifier).
Examples
id <- new_pre_release_identifier(
c("1", "2", "10", "01", "-1", "alpha", "beta", "", NA)
)
id
# empty < numeric < alphanumeric
vctrs::vec_sort(id)
# Works with base R vectors.
id[id == "alpha" & !is.na(id)]
id[id > 2L & !is.na(id)]