Skip to content

Commit 72e28df

Browse files
author
Fatma Degirmenci
committed
Refactor: align numbers in columns (padStart())
1 parent a90ceff commit 72e28df

File tree

1 file changed

+3
-2
lines changed
  • implement-shell-tools/wc

1 file changed

+3
-2
lines changed

implement-shell-tools/wc/wc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { program } from "commander";
32
import { promises as fs } from "node:fs";
43

@@ -28,7 +27,9 @@ function formatOutput(counts, filename, opts) {
2827
if (opts.w) return `${counts.words} ${filename}`;
2928
if (opts.c) return `${counts.bytes} ${filename}`;
3029

31-
return `${counts.lines} ${counts.words} ${counts.bytes} ${filename}`;
30+
return `${String(counts.lines).padStart(8)} ${String(counts.words).padStart(
31+
8
32+
)} ${String(counts.bytes).padStart(8)} ${filename}`;
3233
}
3334

3435
async function main() {

0 commit comments

Comments
 (0)