(defs: Record<string, unknown>)
| 100 | } |
| 101 | |
| 102 | function renameBrandDefinitionKeys(defs: Record<string, unknown>): void { |
| 103 | for (const oldKey of Object.keys(defs)) { |
| 104 | const newKey = fixBrandCasing(oldKey); |
| 105 | if (newKey === oldKey) continue; |
| 106 | if (newKey in defs && stableStringify(defs[newKey]) !== stableStringify(defs[oldKey])) { |
| 107 | throw new Error( |
| 108 | `Brand-casing normalization collision: "${oldKey}" -> "${newKey}" but a different definition already exists under "${newKey}".` |
| 109 | ); |
| 110 | } |
| 111 | defs[newKey] = defs[oldKey]; |
| 112 | delete defs[oldKey]; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | function toPascalCase(name: string): string { |
| 117 | return fixBrandCasing(name.split(/[-_.]/).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("")); |
no test coverage detected
searching dependent graphs…