R/utils.R

Defines functions `%||%` is_counting_number is_named unique_id

`%||%` <- function(a, b) if (is.null(a)) b else a

is_counting_number <- function(x) {
  is.numeric(x) && x > 0 && (x %% 1 == 0)
}

is_named <- function(x) {
  assertthat::has_attr(x, 'names')
}

unique_id <- function() {
  substr(tempfile('', ''), 2, 12)
}
nteetor/roasted documentation built on May 24, 2019, 9:56 a.m.