MCPcopy Create free account
hub / github.com/bilibili/http-service / transformName

Function transformName

scripts/create.ts:16–26  ·  view source on GitHub ↗
(name: string, type: 'camel' | 'Camel' | 'UPPER_SNAKE')

Source from the content-addressed store, hash-verified

14}
15
16const transformName = (name: string, type: 'camel' | 'Camel' | 'UPPER_SNAKE'): string => {
17 return name.split('-').map((s, i) => {
18 if (type === 'UPPER_SNAKE') {
19 if (i === 0) return s.toLocaleUpperCase()
20 return `_${s.toLocaleUpperCase()}`
21 }
22
23 if (type === 'camel' && i === 0) return s
24 return s[0].toLocaleUpperCase() + s.substring(1)
25 }).join('')
26}
27
28const modifyFile = (filePath: string, replaces: Array<string[]>) => {
29 // 1. 读取文件内容

Callers 1

create.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected