R/utils.R

Defines functions is_cran_check safe_examples is_class is_type is_count is_string_or_null is_string

int <- as.integer

is_string <- function(x) {
  is.character(x) && length(x) == 1 && !is.na(x)
}

is_string_or_null <- function(x) {
  is.null(x) || is_string(x)
}

is_count <- function(x) {
  is.integer(x) && length(x) == 1 && !is.na(x)
}

is_type <- function(x) {
  is_count(x)
}

is_class <- function(x) {
  is_count(x)
}

safe_examples <- function() {
  !is_cran_check() && is_online()
}

is_cran_check <- function() {
  if (identical(Sys.getenv("NOT_CRAN"), "true")) {
    FALSE
  } else {
    Sys.getenv("_R_CHECK_PACKAGE_NAME_", "") != ""
  }
}
r-lib/pingr documentation built on June 11, 2025, 5:50 p.m.