Learn R Programming

smvr (version 0.2.0)

pre_release_identifier: 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())

Value

A pre_release_identifier vector.

Arguments

x

Something that can be coerced to a character vector by vctrs::vec_cast(). Each element must be ASCII alphanumerics, hyphens, or empty string (""). Empty string is a special case that means no identifier.

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.

See Also

  • pre_release_ids: Whole pre-release identifiers (Concatenation of pre_release_identifier).

Examples

Run this code
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)]

Run the code above in your browser using DataLab