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

Function getLabelFor

src/lib/table-generator.ts:207–225  ·  view source on GitHub ↗
(definition: TableFieldDefinition<T>)

Source from the content-addressed store, hash-verified

205 }
206
207 const getLabelFor = <T extends object>(definition: TableFieldDefinition<T>): string => {
208 if (typeof definition !== 'object') {
209 return convertToLabel(definition.toString())
210 }
211
212 if (definition.label) {
213 return definition.label
214 }
215
216 if ('value' in definition) {
217 return definition.label
218 }
219
220 if ('prop' in definition) {
221 return convertToLabel(definition.prop.toString())
222 }
223
224 return convertToLabel(definition.path)
225 }
226
227 const getDisplayValueFor = <T extends object>(item: T, definition: TableFieldDefinition<T>): string | undefined => {
228 if (typeof definition === 'object' && 'value' in definition) {

Callers 2

buildTableFromItemFunction · 0.85
buildTableFromListFunction · 0.85

Calls 1

convertToLabelFunction · 0.85

Tested by

no test coverage detected