MCPcopy
hub / github.com/xpf0000/FlyEnv / format

Function format

src/render/util/transform/Go.ts:238–249  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

236
237 // Sanitizes and formats a string to make an appropriate identifier in Go
238 function format(str: string) {
239 str = formatNumber(str)
240
241 const sanitized = toProperCase(str).replace(/[^a-z0-9]/gi, '')
242 if (!sanitized) {
243 return 'NAMING_FAILED'
244 }
245
246 // After sanitizing the remaining characters can start with a number.
247 // Run the sanitized string again trough formatNumber to make sure the identifier is Num[0-9] or Zero_... instead of 1.
248 return formatNumber(sanitized)
249 }
250
251 // Adds a prefix to a number to make an appropriate identifier in Go
252 function formatNumber(str: string) {

Callers 7

logMethod · 0.85
jsonToGoFunction · 0.85
parseStructFunction · 0.85
formatScopeKeysFunction · 0.85
AppLogFunction · 0.85
backupDatabaseMethod · 0.85
backupDatabaseMethod · 0.85

Calls 2

formatNumberFunction · 0.85
toProperCaseFunction · 0.85

Tested by

no test coverage detected