R/script.R

Defines functions stdout_binary code_library code_expression `%||%`

`%||%` <- function(x, y) {
  if (is.null(x)) y else x
}

code_expression <- function(con, ...) {
  writeLines(as.character(rlang::enexprs(...)), con)
}

code_library <- function(con, name) {
  writeLines(paste0("library(", name, ")"), con)
}

stdout_binary <- function() {
  if (.Platform$OS.type == "windows") {
    file("stdout", "wb", raw = TRUE)
  } else {
    file("/dev/stdout", "wb", raw = TRUE)
  }
}
jeroenjanssens/rscl documentation built on Sept. 13, 2021, 12:15 a.m.