From 19543ffec300390f20b577b29d92a58540aaef70 Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Wed, 8 Feb 2023 09:14:40 +0000 Subject: fix(ext/console): Only right-align integers in console.table() (#17389) --- ext/console/02_console.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'ext/console') diff --git a/ext/console/02_console.js b/ext/console/02_console.js index 0bafd532d..a8b335b94 100644 --- a/ext/console/02_console.js +++ b/ext/console/02_console.js @@ -47,6 +47,7 @@ const { StringPrototypeIncludes, StringPrototypeStartsWith, TypeError, + NumberIsInteger, NumberParseInt, RegExp, RegExpPrototype, @@ -232,11 +233,6 @@ function renderRow(row, columnWidths, columnRightAlign) { return out; } -function canRightAlign(value) { - const isNumber = !isNaN(value); - return isNumber; -} - function cliTable(head, columns) { const rows = []; const columnWidths = ArrayPrototypeMap(head, (h) => getStringWidth(h)); @@ -257,7 +253,7 @@ function cliTable(head, columns) { const width = columnWidths[i] || 0; const counted = getStringWidth(value); columnWidths[i] = MathMax(width, counted); - columnRightAlign[i] &= canRightAlign(value); + columnRightAlign[i] &= NumberIsInteger(+value); } } -- cgit v1.2.3