We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8c56b20 commit 6645325Copy full SHA for 6645325
packages/casing/src/index.ts
@@ -6,11 +6,16 @@ export function toPascalCase(str: string) {
6
.replace(/[_\s-]/g, '');
7
}
8
9
-export function toCamelCase(key: string) {
+export function toCamelCase(
10
+ key: string,
11
+ stripLeadingNonAlphabetChars: boolean = false
12
+) {
13
+ if (stripLeadingNonAlphabetChars) {
14
+ // First, remove all leading non-alphabet characters
15
+ key = key.replace(/^[^a-zA-Z]+/, '');
16
+ }
17
return (
18
key
- // First, remove all leading non-alphabet characters
- .replace(/^[^a-zA-Z]+/, '')
19
// Convert what follows a separator into upper case
20
.replace(/[-_\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))
21
// Ensure the first character of the result is always lowercase
0 commit comments