-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathcompat-lifecycle.R
51 lines (44 loc) · 1.06 KB
/
compat-lifecycle.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# nocov start - compat-lifecycle (last updated: rlang 0.3.0.9000)
scoped_lifecycle_silence <- function(frame = rlang::caller_env()) {
rlang::local_options(
.frame = frame,
lifecycle_verbosity = "quiet"
)
}
with_lifecycle_silence <- function(expr) {
scoped_lifecycle_silence()
expr
}
scoped_lifecycle_warnings <- function(frame = rlang::caller_env()) {
rlang::local_options(
.frame = frame,
lifecycle_verbosity = "warning"
)
}
with_lifecycle_warnings <- function(expr) {
scoped_lifecycle_warnings()
expr
}
scoped_lifecycle_errors <- function(frame = rlang::caller_env()) {
rlang::local_options(
.frame = frame,
lifecycle_verbosity = "error"
)
}
with_lifecycle_errors <- function(expr) {
scoped_lifecycle_errors()
expr
}
# Enable once signal_superseded() reaches stable state
signal_superseded <- function(...) {}
foreign_caller_env <- function(my_env = ns_env()) {
for (n in 2:10) {
caller <- caller_env(n)
if (!is_reference(env_parent(caller), my_env)) {
return(caller)
}
}
# Safety net
caller
}
# nocov end