Adjust testing for uppercase words in stringCamelCase (#1538)

* Adjust testing for uppercase words in stringCamelCase

* Use \d

* Revert
This commit is contained in:
Jaco
2022-06-16 16:47:52 +03:00
committed by GitHub
parent 1113d09315
commit 4d887e889a
2 changed files with 9 additions and 2 deletions
+6
View File
@@ -9,7 +9,13 @@ Contributed:
Changes:
- Add `u8aToNumber` (limited, <= 48 bits) function
- Use `~~` as bitwise/faster `Math.floor` replacement
- Remove unneeded `objectSpread` option expansions
- Optimize `hexToU8a` operations
- Optimize `stringCamelCase` operations
- Optimize `u8aToBn` operations
- Additional internal/external comments (as missing)
## 9.4.1 Jun 4, 2022
+3 -2
View File
@@ -11,6 +11,7 @@ for (let i = 0; i < CC_TO_UP.length; i++) {
CC_TO_UP[i] = String.fromCharCode(i).toUpperCase();
}
/** @internal */
function formatRuns (w: string): string {
return w.slice(0, w.length - 1).toLowerCase() + CC_TO_UP[w.charCodeAt(w.length - 1)];
}
@@ -22,7 +23,7 @@ function formatRuns (w: string): string {
// a major improvement over the original camelcase npm package (at running)
//
// original: 20.88 μs/op
// this: 1.09 μs/op
// this: 1.00 μs/op
//
// Caveat of this: only Ascii, but acceptable for the intended usecase
function converter (format: (w: string, i: number) => string): (value: AnyString) => string {
@@ -42,7 +43,7 @@ function converter (format: (w: string, i: number) => string): (value: AnyString
// apply the formatting
result += format(
w.toUpperCase() === w
/^[A-Z0-9]+$/.test(w)
// all full uppercase + letters are changed to lowercase
? w.toLowerCase()
// all consecutive capitals + letters are changed to lowercase