Skip to content

Commit aa98d94

Browse files
committed
Switch argument order to copy_names(from, to).
1 parent a0025ea commit aa98d94

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

R/case.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ NULL
2727
#' @rdname case
2828
str_to_upper <- function(string, locale = "en") {
2929
check_string(locale)
30-
copy_names(stri_trans_toupper(string, locale = locale), string)
30+
copy_names(string, stri_trans_toupper(string, locale = locale))
3131
}
3232
#' @export
3333
#' @rdname case
3434
str_to_lower <- function(string, locale = "en") {
3535
check_string(locale)
36-
copy_names(stri_trans_tolower(string, locale = locale), string)
36+
copy_names(string, stri_trans_tolower(string, locale = locale))
3737
}
3838
#' @export
3939
#' @rdname case
4040
str_to_title <- function(string, locale = "en") {
4141
check_string(locale)
4242
out <- stri_trans_totitle(string,
4343
opts_brkiter = stri_opts_brkiter(locale = locale))
44-
copy_names(out, string)
44+
copy_names(string, out)
4545
}
4646
#' @export
4747
#' @rdname case
@@ -51,5 +51,5 @@ str_to_sentence <- function(string, locale = "en") {
5151
string,
5252
opts_brkiter = stri_opts_brkiter(type = "sentence", locale = locale)
5353
)
54-
copy_names(out, string)
54+
copy_names(string, out)
5555
}

R/compat-purrr.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ map <- function(.x, .f, ...) {
1010
lapply(.x, .f, ...)
1111
}
1212
map_mold <- function(.x, .f, .mold, ...) {
13-
copy_names(vapply(.x, .f, .mold, ..., USE.NAMES = FALSE), .x)
13+
copy_names(.x, vapply(.x, .f, .mold, ..., USE.NAMES = FALSE))
1414
}
1515
map_lgl <- function(.x, .f, ...) {
1616
map_mold(.x, .f, logical(1), ...)

R/conv.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
str_conv <- function(string, encoding) {
1616
check_string(encoding)
1717

18-
copy_names(stri_conv(string, encoding, "UTF-8"), string)
18+
copy_names(string, stri_conv(string, encoding, "UTF-8"))
1919
}

R/escape.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
#' str_detect(c("a", "."), str_escape("."))
1414
str_escape <- function(string) {
1515
out <- str_replace_all(string, "([.^$\\\\|*+?{}\\[\\]()])", "\\\\\\1")
16-
copy_names(out, string)
16+
copy_names(string, out)
1717
}

R/length.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
#' # Because the second element is made up of a u + an accent
3535
#' str_sub(u, 1, 1)
3636
str_length <- function(string) {
37-
copy_names(stri_length(string), string)
37+
copy_names(string, stri_length(string))
3838
}
3939

4040
#' @export
4141
#' @rdname str_length
4242
str_width <- function(string) {
43-
copy_names(stri_width(string), string)
43+
copy_names(string, stri_width(string))
4444
}

R/replace.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fix_replacement_one <- function(x) {
182182
#' str_replace_na(c(NA, "abc", "def"))
183183
str_replace_na <- function(string, replacement = "NA") {
184184
check_string(replacement)
185-
copy_names(stri_replace_na(string, replacement), string)
185+
copy_names(string, stri_replace_na(string, replacement))
186186
}
187187

188188
str_transform <- function(string, pattern, replacement) {

R/trim.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ str_trim <- function(string, side = c("both", "left", "right")) {
2424
right = stri_trim_right(string),
2525
both = stri_trim_both(string)
2626
)
27-
copy_names(out, string)
27+
copy_names(string, out)
2828
}
2929

3030
#' @export
3131
#' @rdname str_trim
3232
str_squish <- function(string) {
33-
copy_names(stri_trim_both(str_replace_all(string, "\\s+", " ")), string)
33+
copy_names(string, stri_trim_both(str_replace_all(string, "\\s+", " ")))
3434
}

R/utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ tr_ <- function(...) {
3030
enc2utf8(gettext(paste0(...), domain = "R-stringr"))
3131
}
3232

33-
copy_names <- function(to, from) {
33+
copy_names <- function(from, to) {
3434
set_names(to, names(from))
3535
}

R/word.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ word <- function(string, start = 1L, end = start, sep = fixed(" ")) {
5252
starts <- mapply(function(word, loc) word[loc, "start"], words, start)
5353
ends <- mapply(function(word, loc) word[loc, "end"], words, end)
5454

55-
copy_names(str_sub(string, starts, ends), string)
55+
copy_names(string, str_sub(string, starts, ends))
5656
}

R/wrap.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ str_wrap <- function(string,
4040
out <- stri_wrap(string, width = width, indent = indent, exdent = exdent,
4141
whitespace_only = whitespace_only, simplify = FALSE)
4242
out <- vapply(out, str_c, collapse = "\n", character(1))
43-
copy_names(out, string)
43+
copy_names(string, out)
4444
}

0 commit comments

Comments
 (0)