diff --git a/CHANGELOG.md b/CHANGELOG.md index 13ef315a8..d5428e038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/util/src/string/camelCase.ts b/packages/util/src/string/camelCase.ts index cce007f11..bdb6f88fa 100644 --- a/packages/util/src/string/camelCase.ts +++ b/packages/util/src/string/camelCase.ts @@ -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