Skip to content

fix[startCase]: only uppercase the first letter of each word like lodash - #2160

Merged
dayongkr merged 1 commit into
mainfrom
fix/compat-start-case
Oct 24, 2026
Merged

dayongkr merged 1 commit into
mainfrom
fix/compat-start-case

Conversation

@dayongkr

Copy link
Copy Markdown
Collaborator

Summary

compat startCase lowercased the rest of every word that was not all uppercase. Since #2097, words keeps camel humps in non-Latin scripts together like lodash, so startCase('ПриветМир') became 'Приветмир' instead of lodash's 'ПриветМир'. lodash only applies upperFirst to each word, by code point.

Changes

  • Uppercase only the first code point of each word and leave the rest as is.
  • Add tests for non-Latin camel humps, mixed case, and a first letter outside the BMP ('𐐨𐐩 deseret' → '𐐀 𐐁 Deseret').

Over 111,189 generated strings, main differs from lodash in 9,317 and v1.52.0 in 93,340. This PR differs in none. The bundle grows by 7 B.

`startCase` lowercased the rest of every word that was not all uppercase. Since
#2097, `words` keeps camel humps in non-Latin scripts together like lodash, so
`startCase('ПриветМир')` turned into `'Приветмир'` instead of lodash's
`'ПриветМир'`. lodash only applies `upperFirst` to each word, and it does so by
code point. Do the same, so astral first letters such as `'𐐨'` are uppercased too.
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
es-toolkit Ready Ready Preview Oct 24, 2026 9:55am UTC

Request Review

@dayongkr
dayongkr marked this pull request as ready for review October 24, 2026 10:11
@dayongkr
dayongkr requested a review from raon0211 as a code owner October 24, 2026 10:11
@dayongkr
dayongkr merged commit 69a4fd1 into main Oct 24, 2026
13 checks passed

This branch was successfully deployed

1 active deployment
Preview — e687ef9e Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant