Skip to content

Commit

Permalink
Remove a bunch of dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Oct 24, 2024
1 parent bc0ebd0 commit a2bbe7a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
6 changes: 3 additions & 3 deletions R/fonts.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ validate_user_alias <- function(default_name, family) {
cli::cli_abort("{.arg family} must can only include elements named {r_font_faces}")

Check warning on line 68 in R/fonts.R

View check run for this annotation

Codecov / codecov/patch

R/fonts.R#L68

Added line #L68 was not covered by tests
}

is_alias_object <- vapply_lgl(family, is_user_alias)
is_alias_plain <- vapply_lgl(family, is_scalar_character)
is_alias_object <- vapply(family, is_user_alias, logical(1))
is_alias_plain <- vapply(family, is_scalar_character, logical(1))

is_valid_alias <- is_alias_object | is_alias_plain
if (any(!is_valid_alias)) {
Expand All @@ -84,7 +84,7 @@ validate_user_alias <- function(default_name, family) {
obj$file %||% obj$ttf
})

file_exists <- vapply_lgl(files, file.exists)
file_exists <- vapply(files, file.exists, logical(1))
if (any(!file_exists)) {
missing <- unlist(files)[!file_exists]
cli::cli_abort("Could not find the following font file{?s}: {missing}")

Check warning on line 90 in R/fonts.R

View check run for this annotation

Codecov / codecov/patch

R/fonts.R#L90

Added line #L90 was not covered by tests
Expand Down
24 changes: 1 addition & 23 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,22 @@ plot_dim <- function(dim = c(NA, NA)) {
dim
}

vapply_chr <- function(.x, .f, ...) {
vapply(.x, .f, character(1), ...)
}
vapply_lgl <- function(.x, .f, ...) {
vapply(.x, .f, logical(1), ...)
}
lapply_if <- function(.x, .p, .f, ...) {
if (!is.logical(.p)) {
.p <- vapply_lgl(.x, .p)
.p <- vapply(.x, .p, logical(1))

Check warning on line 23 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L23

Added line #L23 was not covered by tests
}
.x[.p] <- lapply(.x[.p], .f, ...)
.x
}
keep <- function(.x, .p, ...) {
.x[vapply_lgl(.x, .p, ...)]
}
compact <- function(x) {
Filter(length, x)
}
is_scalar_character <- function(x) {
is.character(x) && length(x) == 1
}
names2 <- function(x) {
names(x) %||% rep("", length(x))
}
ilapply <- function(.x, .f, ...) {
idx <- names(.x) %||% seq_along(.x)
out <- Map(.f, names(.x), .x, ...)
names(out) <- names(.x)
out
}
ilapply_if <- function(.x, .p, .f, ...) {
if (!is.logical(.p)) {
.p <- vapply_lgl(.x, .p)
}
.x[.p] <- ilapply(.x[.p], .f, ...)
.x
}
set_names <- function(x, nm = x) {
stats::setNames(x, nm)
}
Expand Down

0 comments on commit a2bbe7a

Please sign in to comment.