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

Function buildTableFromItem

src/lib/table-generator.ts:259–274  ·  view source on GitHub ↗
(item: T, definitions: TableFieldDefinition<T>[])

Source from the content-addressed store, hash-verified

257 }
258
259 const buildTableFromItem = <T extends object>(item: T, definitions: TableFieldDefinition<T>[]): string => {
260 const table = newOutputTable()
261 for (const definition of definitions) {
262 if (typeof definition !== 'object'
263 || definition.include === undefined
264 || definition.include(item)) {
265 const value = getDisplayValueFor(item, definition)
266 if (typeof definition !== 'object'
267 || !definition.skipEmpty
268 || value) {
269 table.push([getLabelFor(definition), value])
270 }
271 }
272 }
273 return table.toString()
274 }
275
276 const buildTableFromList = <T extends object>(items: T[], definitions: TableFieldDefinition<T>[]): string => {
277 const headingLabels = definitions.map(def => getLabelFor(def))

Callers

nothing calls this directly

Calls 3

newOutputTableFunction · 0.85
getDisplayValueForFunction · 0.85
getLabelForFunction · 0.85

Tested by

no test coverage detected