Skip to content

Commit

Permalink
fix: prevent table from throwing with negative numbers in .repeat() (#40
Browse files Browse the repository at this point in the history
)
  • Loading branch information
leifssm authored Jan 22, 2024
1 parent 3ef9c71 commit cad3c03
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ export class Table extends Component {
let value = "";

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

return value;
Expand Down

0 comments on commit cad3c03

Please sign in to comment.