Created
March 17, 2026 03:26
-
-
Save jonathanconway/38dae43fbab51aa066bff3c78a8264f9 to your computer and use it in GitHub Desktop.
Converts provided string to PascalCase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { kebabCase, startCase } from "lodash"; | |
| /** | |
| * Converts provided string to PascalCase | |
| * @example my-string => MyString | |
| * @example myString => MyString | |
| * @example my_string => MyString | |
| * @example MY_STRING => MyString | |
| */ | |
| export function pascalCase(input: string) { | |
| return kebabCase(input).split("-").map(startCase).filter(Boolean).join(""); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment