summaryrefslogtreecommitdiff
path: root/lib/internal/util/inspect.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-06-05 14:57:46 +0200
committerRuben Bridgewater <ruben@bridgewater.de>2019-06-17 11:49:42 +0200
commitb97b003c352cf9da5885ac0a5516fee0a767f134 (patch)
tree40c6fa33fa526ac03d80d47109168c5c87ebb365 /lib/internal/util/inspect.js
parent87a22cff77f923d69797c29a766b21f63f8dc5a9 (diff)
downloadandroid-node-v8-b97b003c352cf9da5885ac0a5516fee0a767f134.tar.gz
android-node-v8-b97b003c352cf9da5885ac0a5516fee0a767f134.tar.bz2
android-node-v8-b97b003c352cf9da5885ac0a5516fee0a767f134.zip
util: use average bias while grouping arrays
This makes sure that strongly deviating entry length are taken into account while grouping arrays. PR-URL: https://github.com/nodejs/node/pull/28070 Refs: https://github.com/nodejs/node/issues/27690 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/util/inspect.js')
-rw-r--r--lib/internal/util/inspect.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js
index ed68ebed16..b8f1c4f0af 100644
--- a/lib/internal/util/inspect.js
+++ b/lib/internal/util/inspect.js
@@ -997,7 +997,8 @@ function groupArrayElements(ctx, output, value) {
(totalLength / actualMax > 5 || maxLength <= 6)) {
const approxCharHeights = 2.5;
- const biasedMax = Math.max(actualMax - 4, 1);
+ const averageBias = Math.sqrt(actualMax - totalLength / output.length);
+ const biasedMax = Math.max(actualMax - 3 - averageBias, 1);
// Dynamically check how many columns seem possible.
const columns = Math.min(
// Ideally a square should be drawn. We expect a character to be about 2.5