Skip to content

Commit f4f9d1f

Browse files
committed
lib: honor util.inspect breakLength Infinity
1 parent 76d70a6 commit f4f9d1f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/internal/util/inspect.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,14 @@ function formatError(err, constructor, tag, ctx, keys) {
20222022
return stack;
20232023
}
20242024

2025+
function isUnlimitedDepth(ctx) {
2026+
return ctx.depth === null || ctx.depth === Infinity;
2027+
}
2028+
20252029
function groupArrayElements(ctx, output, value) {
2030+
if (!NumberIsFinite(ctx.breakLength) && isUnlimitedDepth(ctx)) {
2031+
return output;
2032+
}
20262033
let totalLength = 0;
20272034
let maxLength = 0;
20282035
let i = 0;
@@ -2640,8 +2647,10 @@ function reduceToSingleString(
26402647
// Consolidate all entries of the local most inner depth up to
26412648
// `ctx.compact`, as long as the properties are smaller than
26422649
// `ctx.breakLength`.
2643-
if (ctx.currentDepth - recurseTimes < ctx.compact &&
2644-
entries === output.length) {
2650+
const allowInline =
2651+
(!NumberIsFinite(ctx.breakLength) && isUnlimitedDepth(ctx)) ||
2652+
ctx.currentDepth - recurseTimes < ctx.compact;
2653+
if (allowInline && entries === output.length) {
26452654
// Line up all entries on a single line in case the entries do not
26462655
// exceed `breakLength`. Add 10 as constant to start next to all other
26472656
// factors that may reduce `breakLength`.

0 commit comments

Comments
 (0)