Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breakLength inspect option is not respected with four or more levels of deepness when depth option is 3 or more #45193

Closed
DamienGarrido opened this issue Oct 26, 2022 · 2 comments
Labels
doc Issues and PRs related to the documentations. util Issues and PRs related to the built-in util module.

Comments

@DamienGarrido
Copy link

Version

v18.12.0

Platform

Linux ubuntu 5.11.0-38-generic #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

util

What steps will reproduce the bug?

const { inspect } = require('util');
const inspectOptions = { depth: 3, breakLength: Infinity };

const obj_1 = { one: { two: { three: 'cool!' } } };
const obj_2 = { one: { two: { three: { four: 'boom!' } } } };

console.log(inspect(obj_1, inspectOptions));
console.log(inspect(obj_2, inspectOptions));

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

{ one: { two: { three: 'cool!' } } }
{ one: { two: { three: { four: 'boom!' } } } }

What do you see instead?

{ one: { two: { three: 'cool!' } } }
{
  one: { two: { three: { four: 'boom!' } } }
}

Additional information

No response

@cola119 cola119 added the util Issues and PRs related to the built-in util module. label Oct 26, 2022
@BridgeAR
Copy link
Member

BridgeAR commented Jan 5, 2023

The behavior above seems correct to me. Our documentation seems a bit off though. The reason is that compact is set to 3 by default. That means only up to the three most inner elements are combined to a single line, as long as these elements all fit into breakLength. If e.g., the most two inner ones would already exceed breakLength, then the line would already be separated earlier.

If you want to have a single line, please also set compact to Infinity.

@BridgeAR BridgeAR added the doc Issues and PRs related to the documentations. label Jan 5, 2023
@BridgeAR
Copy link
Member

BridgeAR commented Nov 4, 2024

Since there was no follow-up, I am going to close this as working as expected.

@BridgeAR BridgeAR closed this as completed Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

No branches or pull requests

3 participants