Skip to content

Commit

Permalink
fix: check array bounds to avoid deoptimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Jul 22, 2024
1 parent 370513f commit 72092a6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function textTable(rows: string[][], opts: TextTableOptions = {}) {
row.forEach(function (row, i) {
const rowLength = stringLength(row);

if (!acc[i] || rowLength > acc[i]) {
if (i >= acc.length || !acc[i] || rowLength > acc[i]) {
acc[i] = rowLength;
}
});
Expand Down

0 comments on commit 72092a6

Please sign in to comment.