Align text.

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

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

Loading…
Cancel
Save