Skip to content

Commit cad3c03

Browse files
authored
fix: prevent table from throwing with negative numbers in .repeat() (#40)
1 parent 3ef9c71 commit cad3c03

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/components/table.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ export class Table extends Component {
235235
let value = "";
236236

237237
for (const header of headers) {
238-
value += header.title + " ".repeat(header.width + 1 - textWidth(header.title));
238+
// Ensures non-negative numbers
239+
const endPadding = Math.max(0, header.width + 1 - textWidth(header.title));
240+
value += header.title + " ".repeat(endPadding);
239241
}
240242

241243
return value;

0 commit comments

Comments
 (0)