import_objs.Rd
Statically import specific objects
import_objs(
names,
source = system.file("staticexports", package = "staticimports"),
outfile = here::here("R/staticimports.R"),
label = NULL,
append = FALSE
)
A character vector of names of objects to import.
A directory containing source files, or an environment to use as the source.
File to write to. Defaults to R/staticimports.R in the current
project. Use stdout()
to output to console.
A label to write to the file, to indicate where the objects were imported from.
If TRUE
, append to the output file; otherwise overwrite.
if (interactive()) {
# Import `os_name` and `walk` into your project
import_objs(c("os_name", "walk"))
}
# Write to stdout instead of R/staticimports.R
import_objs(c("os_name", "walk"), outfile = stdout())
#> # Generated by staticimports; do not edit by hand.
#> # ======================================================================
#>
#> is_emscripten <- function() Sys.info()[["sysname"]] == "Emscripten"
#>
#> is_linux <- function() Sys.info()[["sysname"]] == "Linux"
#>
#> is_mac <- function() Sys.info()[["sysname"]] == "Darwin"
#>
#> is_windows <- function() .Platform$OS.type == "windows"
#>
#> os_name <- function() {
#> if (is_windows()) {
#> "win"
#> } else if (is_mac()) {
#> "mac"
#> } else if (is_linux()) {
#> "linux"
#> } else if (is_emscripten()) {
#> "emscripten"
#> } else if (.Platform$OS.type == "unix") {
#> "unix"
#> } else {
#> "unknown"
#> }
#> }
#>
#> walk <- function(.x, .f, ...) {
#> for (i in seq_along(.x)) {
#> .f(.x[[i]], ...)
#> }
#> NULL
#> }