MCPcopy
hub / github.com/prisma/prisma / formatTable

Function formatTable

packages/internals/src/utils/formatTable.ts:9–20  ·  view source on GitHub ↗
(rows: string[][], options = { json: false } as FormatTableOptions)

Source from the content-addressed store, hash-verified

7}
8
9export function formatTable(rows: string[][], options = { json: false } as FormatTableOptions): string {
10 if (options.json) {
11 const result = rows.reduce((acc, [name, value]) => {
12 acc[slugify(name)] = value
13 return acc
14 }, {})
15 return JSON.stringify(result, null, 2)
16 }
17
18 const maxPad = rows.reduce((acc, curr) => Math.max(acc, curr[0].length), 0)
19 return rows.map(([left, right]) => `${left.padEnd(maxPad)} : ${right}`).join('\n')
20}

Callers 3

parseMethod · 0.90

Calls 1

slugifyFunction · 0.85

Tested by

no test coverage detected