Align text.

pull/11/head
Attacktive 3 years ago
parent 401175f1a4
commit 69d37e0962

@ -3,10 +3,14 @@ const history: History = {};
let historyIndex = 0;
export function list(): string {
const maximumNumberOfDigits = historyIndex.toString().length;
const array: Array<string> = [];
for (const index in history) {
const value: string = history[index];
array.push(`${index}: ${value}`);
const value = history[index];
const paddedIndex = index.toString().padStart(maximumNumberOfDigits, ' ');
array.push(`${paddedIndex}: ${value}`);
}
return array.join('\n');

Loading…
Cancel
Save