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

util: add an option for configuring break length #7499

Merged
merged 1 commit into from
Jul 5, 2016

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Jun 30, 2016

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

util

Description of change

This commit adds a breakLength option to util.inspect(). This option allows users to control the length at which object keys are split across multiple lines. For backwards compatibility, this option defaults to 60.

Fixes: #7305

@mscdex mscdex added the util Issues and PRs related to the built-in util module. label Jun 30, 2016
@evanlucas evanlucas added the semver-minor PRs that contain new features and should be released in the next minor version. label Jun 30, 2016
@evanlucas
Copy link
Contributor

LGTM if CI is happy

@@ -194,6 +194,7 @@ function inspect(obj, opts) {
if (ctx.colors) ctx.stylize = stylizeWithColor;
if (ctx.maxArrayLength === undefined) ctx.maxArrayLength = kDefaultMaxLength;
if (ctx.maxArrayLength === null) ctx.maxArrayLength = Infinity;
if (ctx.breakLength === undefined) ctx.breakLength = 60;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about setting to null or Infinity... what affect would that need to have? Just thinking about consistency with other options

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I picked 60 to maintain backwards compatibility. I could assign it to null or Infinity and then change the value later, but it seems like that would only complicate things.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 60 is fine, but if set to null or Infinity explicitly we should figure out what the behavior should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Infinity is documented to make the object print on a single line with no breaks. null, or any value for that matter, will be plugged in for breakLength in the length > breakLength comparison.

@jasnell
Copy link
Member

jasnell commented Jun 30, 2016

LGTM with a nit

@Fishrock123
Copy link
Contributor

seems fine to me

@cjihrig
Copy link
Contributor Author

cjihrig commented Jul 1, 2016

This commit adds a breakLength option to util.inspect(). This
option allows users to control the length at which object keys
are split across multiple lines. For backwards compatibility,
this option defaults to 60.

Fixes: nodejs#7305
PR-URL: nodejs#7499
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
@cjihrig cjihrig merged commit a2ee21d into nodejs:master Jul 5, 2016
@cjihrig cjihrig deleted the 7305 branch July 5, 2016 14:52
@Fishrock123 Fishrock123 mentioned this pull request Jul 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor PRs that contain new features and should be released in the next minor version. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants