R/util_assert.R

Defines functions assert_raw assert_is

assert_is <- function(x, what, name = deparse(substitute(x))) {
  if (!inherits(x, what)) {
    stop(sprintf("'%s' must be a %s", name,
                 paste(what, collapse = " / ")), call. = FALSE)
  }
}

assert_raw <- function(x, name = deparse(substitute(x))) {
  if (!is.raw(x) && !is.na(x)) {
    stop(sprintf("%s must be raw", name), call. = FALSE)
  }
}

Try the cyphr package in your browser

Any scripts or data that you put into this service are public.

cyphr documentation built on June 20, 2022, 5:17 p.m.