R/pause.R

Defines functions pause

Documented in pause

#' @encoding UTF-8
#' @title Pause execution.
#' @family meta
#' @description Pause for `x` seconds, then resume execution.
#' @param x A \link[=cmp_nng_scl]{complete non-netative numeric scalar} indicating the number of seconds to pause.
#' @return `NULL` (called for its side effect).
#' @examples
#' \dontrun{
#'   cat("\n pause(0.01)")
#'   pause(0.01)
#'   cat("\n pause(0.1)")
#'   pause(0.1)
#'   cat("\n pause(0.2)")
#'   pause(0.2)
#'   cat("\n pause(0.5)")
#'   pause(0.5)
#'   cat("\n pause(1)")
#'   pause(1)
#'   cat("\n done")
#' }
#' @export
pause <- function(x = 0.0000001) {
  if (!uj::.cmp_nng_scl(x)) {uj::stopperr("[x] must be a non-NA, non-negative, numeric scalar.")}
  base::Sys.sleep(x)
}
j-martineau/uj documentation built on Sept. 14, 2024, 4:40 a.m.