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: use constructor name #14886

Closed
wants to merge 1 commit into from

Conversation

BridgeAR
Copy link
Member

For circular references util.inspect always prints Array
or Object not matter if it is a subclass or not.

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

util

@nodejs-github-bot nodejs-github-bot added the util Issues and PRs related to the built-in util module. label Aug 17, 2017
lib/util.js Outdated
} else if (Array.isArray(value)) {
if (constructor)
return ctx.stylize(`[${constructor.name}]`, 'special');
if (Array.isArray(value))
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this check is redundant as soon as #14881 has landed. Right now Arrays set the constructor to null and the check has to be done again.

@BridgeAR BridgeAR added the semver-major PRs that contain breaking changes and should be released in the next major version. label Aug 17, 2017
@TimothyGu
Copy link
Member

Commit message nit: doesn't this apply to objects that exceed the depth limit rather than circular objects? Or both?

@BridgeAR
Copy link
Member Author

@TimothyGu you are absolutely right! Fixed

@BridgeAR
Copy link
Member Author

PTAL I changed the commit message and this could land otherwise.

@hiroppy
Copy link
Member

hiroppy commented Aug 26, 2017

@BridgeAR
Copy link
Member Author

I would like to land this after #14881 as that one would otherwise not cleanly land on 8.x. Otherwise I would have already landed that. Marking this as blocked because of that.

@BridgeAR BridgeAR added the blocked PRs that are blocked by other issues or PRs. label Aug 26, 2017
@BridgeAR BridgeAR removed the blocked PRs that are blocked by other issues or PRs. label Sep 15, 2017
When reaching the depth limit util.inspect always prints [Array]
or [Object] no matter if it is a subclass or not.
This fixes it by showing the actual constructor name instead.
@BridgeAR
Copy link
Member Author

Rebased. PTAL, I would like to land this very soon.

@BridgeAR
Copy link
Member Author

@BridgeAR
Copy link
Member Author

Landed in b1c8f15

@BridgeAR BridgeAR closed this Sep 19, 2017
BridgeAR added a commit that referenced this pull request Sep 19, 2017
When reaching the depth limit util.inspect always prints [Array]
or [Object] no matter if it is a subclass or not.
This fixes it by showing the actual constructor name instead.

PR-URL: #14886
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Qard pushed a commit to Qard/ayo that referenced this pull request Sep 21, 2017
When reaching the depth limit util.inspect always prints [Array]
or [Object] no matter if it is a subclass or not.
This fixes it by showing the actual constructor name instead.

PR-URL: nodejs/node#14886
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Qard pushed a commit to Qard/ayo that referenced this pull request Sep 21, 2017
When reaching the depth limit util.inspect always prints [Array]
or [Object] no matter if it is a subclass or not.
This fixes it by showing the actual constructor name instead.

PR-URL: nodejs/node#14886
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@BridgeAR BridgeAR deleted the add-proper-constructor branch April 1, 2019 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-major PRs that contain breaking changes and should be released in the next major 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.

7 participants