Skip to content

Commit 1f15510

Browse files
chore: rebase
1 parent bd819f5 commit 1f15510

File tree

3 files changed

+689
-123
lines changed

3 files changed

+689
-123
lines changed

src/utils.js

-62
Original file line numberDiff line numberDiff line change
@@ -80,68 +80,6 @@ function camelCase(input) {
8080
.replace(/\d+([\p{Alpha}\p{N}_]|$)/gu, (m) => m.toUpperCase());
8181
}
8282

83-
const preserveCamelCase = (string) => {
84-
let result = string;
85-
let isLastCharLower = false;
86-
let isLastCharUpper = false;
87-
let isLastLastCharUpper = false;
88-
89-
for (let i = 0; i < result.length; i++) {
90-
const character = result[i];
91-
92-
if (isLastCharLower && /[\p{Lu}]/u.test(character)) {
93-
result = `${result.slice(0, i)}-${result.slice(i)}`;
94-
isLastCharLower = false;
95-
isLastLastCharUpper = isLastCharUpper;
96-
isLastCharUpper = true;
97-
i += 1;
98-
} else if (
99-
isLastCharUpper &&
100-
isLastLastCharUpper &&
101-
/[\p{Ll}]/u.test(character)
102-
) {
103-
result = `${result.slice(0, i - 1)}-${result.slice(i - 1)}`;
104-
isLastLastCharUpper = isLastCharUpper;
105-
isLastCharUpper = false;
106-
isLastCharLower = true;
107-
} else {
108-
isLastCharLower =
109-
character.toLowerCase() === character &&
110-
character.toUpperCase() !== character;
111-
isLastLastCharUpper = isLastCharUpper;
112-
isLastCharUpper =
113-
character.toUpperCase() === character &&
114-
character.toLowerCase() !== character;
115-
}
116-
}
117-
118-
return result;
119-
};
120-
121-
function camelCase(input) {
122-
let result = input.trim();
123-
124-
if (result.length === 0) {
125-
return "";
126-
}
127-
128-
if (result.length === 1) {
129-
return result.toLowerCase();
130-
}
131-
132-
const hasUpperCase = result !== result.toLowerCase();
133-
134-
if (hasUpperCase) {
135-
result = preserveCamelCase(result);
136-
}
137-
138-
return result
139-
.replace(/^[_.\- ]+/, "")
140-
.toLowerCase()
141-
.replace(/[_.\- ]+([\p{Alpha}\p{N}_]|$)/gu, (_, p1) => p1.toUpperCase())
142-
.replace(/\d+([\p{Alpha}\p{N}_]|$)/gu, (m) => m.toUpperCase());
143-
}
144-
14583
function escape(string) {
14684
let output = "";
14785
let counter = 0;

0 commit comments

Comments
 (0)