Debian Codegraph @

R/once.R

raw
1
2 # mechanism for running a block of code only once
3 the$once <- new.env(parent = emptyenv())
4
5 once <- function() {
6
7 call <- sys.call(sys.parent())[[1L]]
8 id <- as.character(call)
9
10 once <- the$once[[id]] %||% TRUE
11 the$once[[id]] <- FALSE
12
13 once
14
15 }