MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / convertToLabel

Function convertToLabel

src/lib/table-generator.ts:194–205  ·  view source on GitHub ↗
(propertyName: string)

Source from the content-addressed store, hash-verified

192 const logger = log4js.getLogger('table-manager')
193
194 const convertToLabel = (propertyName: string): string => {
195 // We only use the last field for the name if it's a nested property.
196 const propertyNames = propertyName.split('.')
197 return propertyNames[propertyNames.length - 1]
198 .replace(/([a-z])([A-Z])/g, '$1 $2')
199 .replace(/^([a-z])/, text => text.toUpperCase())
200 .replace(/\bUri\b/, 'URI')
201 .replace(/\bUrl\b/, 'URL')
202 .replace(/\bArn\b/, 'ARN')
203 .replace(/\bO ?[Aa]uth\b/, 'OAuth')
204 .replace(/^Is /, '')
205 }
206
207 const getLabelFor = <T extends object>(definition: TableFieldDefinition<T>): string => {
208 if (typeof definition !== 'object') {

Callers 1

getLabelForFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected