(obj: JSONObject)
| 102 | } |
| 103 | |
| 104 | function formatSingleObject(obj: JSONObject): string { |
| 105 | const useColor: boolean = !isColorDisabled(); |
| 106 | |
| 107 | const table: Table.Table = new Table({ |
| 108 | style: { head: [], border: [] }, |
| 109 | }); |
| 110 | |
| 111 | for (const [key, value] of Object.entries(obj)) { |
| 112 | const label: string = useColor ? chalk.cyan(key) : key; |
| 113 | table.push({ [label]: truncateValue(value as JSONValue) }); |
| 114 | } |
| 115 | |
| 116 | return table.toString(); |
| 117 | } |
| 118 | |
| 119 | function truncateValue(val: JSONValue, maxLen: number = 60): string { |
| 120 | if (val === null || val === undefined) { |
no test coverage detected