MCPcopy Create free account
hub / github.com/Tatamo/atcoder-cli / formatAsShellOutput

Function formatAsShellOutput

src/commands.ts:459–463  ·  view source on GitHub ↗

* 文字列の2次元配列を受け取り、行ごとにいい感じのスペースで結合して返す * @param data

(data: Array<Array<string>>)

Source from the content-addressed store, hash-verified

457 * @param data
458 */
459function formatAsShellOutput(data: Array<Array<string>>): string {
460 const padding = " ";
461 const max_lengths = data.map(arr => arr.map(str => str.length)).reduce((a, b) => a.map((v, i) => Math.max(v, b[i])));
462 return data.map(line => line.reduceRight((p, c, i) => c.padEnd(max_lengths[i]) + padding + p)).join("\n");
463}
464
465/**
466 * プロセスがTTYで実行されているならSGRでスタイルを適用する

Callers 2

formatFunction · 0.85
getTemplateListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected