MCPcopy Create free account
hub / github.com/dethcrypto/TypeChain / normalizeName

Function normalizeName

packages/typechain/src/parser/normalizeName.ts:6–23  ·  view source on GitHub ↗
(rawName: string)

Source from the content-addressed store, hash-verified

4 * Converts valid file names to valid javascript symbols and does best effort to make them readable. Example: ds-token.test becomes DsTokenTest
5 */
6export function normalizeName(rawName: string): string {
7 const transformations: ((s: string) => string)[] = [
8 (s) => s.replace(/\s+/g, '-'), // spaces to - so later we can automatically convert them
9 (s) => s.replace(/\./g, '-'), // replace "."
10 (s) => s.replace(/-[a-z]/g, (match) => match.substr(-1).toUpperCase()), // delete '-' and capitalize the letter after them
11 (s) => s.replace(/-/g, ''), // delete any '-' left
12 (s) => s.replace(/^\d+/, ''), // removes leading digits
13 (s) => upperFirst(s),
14 ]
15
16 const finalName = transformations.reduce((s, t) => t(s), rawName)
17
18 if (finalName === '') {
19 throw new Error(`Can't guess class name, please rename file: ${rawName}`)
20 }
21
22 return finalName
23}

Callers 6

afterRunMethod · 0.90
afterRunMethod · 0.90
constructorMethod · 0.90
parseContractPathFunction · 0.90
createBarrelFilesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…