R/capture.R

Defines functions capture

Documented in capture

#' Capture Three Dots
#' 
#' @param ... Three dots.
#' 
#' @keywords internal
capture <- function(...){
  qs <- rlang::enquos(...)
  
  quosures <- lapply(qs, function(x, env){
    rlang::new_quosure(x, env = env)
  }, env = parent.frame())

  eval <- lapply(quosures, function(x){
    try <- tryCatch(rlang::eval_tidy(x), error = function(e) e)

    if(rlang::is_function(try))
      return(x)

    if(!inherits(try, "error"))
      return(try)
    
    x
  })
}
JohnCoene/linne documentation built on Jan. 16, 2022, 3:54 a.m.