move js to suggests

This commit is contained in:
Tom Elliott 2025-01-22 20:51:34 +13:00
parent adef247c2a
commit da186429eb
2 changed files with 12 additions and 5 deletions

View File

@ -10,11 +10,11 @@ License: MIT + file LICENSE
Encoding: UTF-8 Encoding: UTF-8
Roxygen: list(markdown = TRUE) Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1 RoxygenNote: 7.3.1
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3 Config/testthat/edition: 3
Imports: Imports:
cli, cli,
js,
rlang, rlang,
Rserve Rserve
Suggests:
testthat (>= 3.0.0),
js

View File

@ -30,14 +30,14 @@ print.ts_object <- function(x, ...) {
cli::cli_ul() cli::cli_ul()
cli::cli_h3("Input type: ") cli::cli_h3("Input type: ")
if (nchar(x$input_type) > 50) { if (nchar(x$input_type) > 50) {
cat(js::uglify_reformat(x$input_type, beautify = TRUE), "\n") cat(format_js(x$input_type), "\n")
} else { } else {
cat(x$input_type, "\n") cat(x$input_type, "\n")
} }
cli::cli_h3("Return type: ") cli::cli_h3("Return type: ")
if (nchar(x$return_type) > 50) { if (nchar(x$return_type) > 50) {
print(x$return_type) print(x$return_type)
cat(js::uglify_reformat(x$return_type, beautify = TRUE), "\n") cat(format_js(x$return_type), "\n")
} else { } else {
cat(x$return_type, "\n") cat(x$return_type, "\n")
} }
@ -397,3 +397,10 @@ ts_void <- function() {
} }
) )
} }
format_js <- function(x) {
if (!requireNamespace("js", quietly = TRUE)) {
return(x)
}
js::uglify_reformat(x, beautify = TRUE)
}