R/helpers.R

Defines functions file.create `%|>|%` read_lines find.template

# nocov start
# base --------------------------------------------------------------------
find.template <- function(...){
    path <- base::system.file(..., package = "ddd")
    if(nchar(path) == 0) path <- base::system.file("inst", ..., package = "ddd", mustWork = TRUE)
    return(path)
}
read_lines <- function(con) base::readLines(con) %>% str_flatten()
`%|>|%` <- function(a, b = identity){ if(is.null(a)) return(NULL) else return(b(a)) }

# fs ----------------------------------------------------------------------
file.create <- function(path) {dir.create(dirname(path), F, T); fs::file_create(path)}

# tidyverse ---------------------------------------------------------------
str_flatten <- purrr::partial(stringr::str_flatten, collapse = "\n")
str_glue_data <- stringr::str_glue_data
str_glue <- stringr::str_glue
# nocov end
tidylab/ddd documentation built on Jan. 6, 2021, 8:16 a.m.