GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — util: improve display of iterators and weak entries by BridgeAR · Pull Request #20961 · nodejs/node

Conversation

@BridgeAR

@BridgeAR BridgeAR commented May 25, 2018

Copy link
Copy Markdown
Member

This is based on #20831 and I am going to rebase when that lands.

This patch changes the way how map iterator entries are displayed by
using the same style as for regular maps. It also improves iterators
in general as well as WeakSets and WeakMaps by indicating how many
entries in total exist. This information was not available before but
due to the new preview implementation it is now available and should
be displayed as well.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BridgeAR
BridgeAR requested a review from addaleax May 25, 2018 10:21
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. console Issues and PRs related to the console subsystem. util Issues and PRs related to the built-in util module. labels May 25, 2018
@BridgeAR

BridgeAR commented May 25, 2018

Copy link
Copy Markdown
Member Author

CI https://ci.nodejs.org/job/node-test-pull-request/15094/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR BridgeAR added the blocked PRs that are blocked by other issues or PRs. label May 25, 2018
@TimothyGu

TimothyGu commented May 25, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I like the change that adds the number of omitted items, but I feel inspection need to display what is to come from the iterator (i.e., what will be returned the next time one calls it.next()), not what is in the Map backing the iterator. As such I prefer the original array styling for .entries().

You might also want to do the same change to URLSearchParams.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR

BridgeAR commented May 25, 2018

Copy link
Copy Markdown
Member Author

@TimothyGu the styling for .entries() here is coherent with the way Chrome does it.

Currently there is no special handling for URLSearchParams but I can check how they currently look like.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TimothyGu

TimothyGu commented May 25, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I don't think we have an obligation to always follow what Chrome does, or at least I feel consistency in showing what's returned from .next() should be posited at a higher level of importance than copying Chrome's behavior.

URLSearchParams Iterator class has a custom inspection function, but I'd be more than okay to leave it out for another PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR

BridgeAR commented May 26, 2018

Copy link
Copy Markdown
Member Author

@TimothyGu I gave it another thought and I agree with you. As soon as this PR is unblocked, I'll rebase and undo the changes to the inspection of Map#entries.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR
BridgeAR force-pushed the improve-util-inspect-output branch from 4b92277 to 61cd6ba Compare July 14, 2018 15:05
@BridgeAR BridgeAR removed the blocked PRs that are blocked by other issues or PRs. label Jul 14, 2018
@BridgeAR
BridgeAR force-pushed the improve-util-inspect-output branch 2 times, most recently from fc452f9 to acd59c3 Compare July 16, 2018 12:59
@BridgeAR
util: improve display of iterators and weak entries
591923b
This adds the number of not visible elements when inspecting iterators
while exceeding `maxArrayLength`.
It also fixes a edge case with `maxArrayLength` and the map.entries()
iterator. Now the whole entry will be visible instead of only the key
but not the value of the first entry.
Besides that it uses a slighly better algorithm that improves the
performance by skipping unnecessary steps.
@BridgeAR
BridgeAR force-pushed the improve-util-inspect-output branch from acd59c3 to 591923b Compare July 16, 2018 13:11
@BridgeAR

BridgeAR commented Jul 16, 2018

Copy link
Copy Markdown
Member Author

CI https://ci.nodejs.org/job/node-test-pull-request/15894/

This is unblocked since the other PR landed.

@TimothyGu I switched it back to the array notation for map entries and fixes a edge case that prevented the whole first entry from being visible in combination with maxArrayLength.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina approved these changes Jul 16, 2018
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. Are you confident in this being a patch?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BridgeAR

BridgeAR commented Jul 16, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

@mcollina I'd say it is a fix. It was never meant to only visualize the key in combination with maxArrayLength: 1 and the only reason it did not yet show the number of missing properties is that this information was not available with the original implementation. Besides that we have a doc note that says that no one should rely on the output programmatically due to changes like these.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR
BridgeAR requested a review from TimothyGu July 17, 2018 17:44
@BridgeAR BridgeAR added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Jul 18, 2018
@BridgeAR

BridgeAR commented Jul 18, 2018

Copy link
Copy Markdown
Member Author

It would be nice to get another review before this lands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax
addaleax approved these changes Jul 18, 2018
View reviewed changes
BridgeAR added a commit to BridgeAR/node that referenced this pull request Jul 18, 2018
@BridgeAR
util: improve display of iterators and weak entries
81bc23f
This adds the number of not visible elements when inspecting iterators
while exceeding `maxArrayLength`.
It also fixes a edge case with `maxArrayLength` and the map.entries()
iterator. Now the whole entry will be visible instead of only the key
but not the value of the first entry.
Besides that it uses a slighly better algorithm that improves the
performance by skipping unnecessary steps.

PR-URL: nodejs#20961
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@BridgeAR

BridgeAR commented Jul 18, 2018

Copy link
Copy Markdown
Member Author

Landed in 81bc23f 🎉

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR BridgeAR closed this Jul 18, 2018
@targos targos added backport-requested-v10.x and removed author ready PRs with CI started, the required approvals, and no outstanding review comments. labels Jul 19, 2018
@targos

targos commented Jul 19, 2018

Copy link
Copy Markdown
Member

Should this be backported to v10.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos targos mentioned this pull request Jul 31, 2018
util: harden util.inspect #21869
Closed
4 tasks done
rvagg pushed a commit that referenced this pull request Aug 13, 2018
@BridgeAR @rvagg
util: improve display of iterators and weak entries
df087cf
This adds the number of not visible elements when inspecting iterators
while exceeding `maxArrayLength`.
It also fixes a edge case with `maxArrayLength` and the map.entries()
iterator. Now the whole entry will be visible instead of only the key
but not the value of the first entry.
Besides that it uses a slighly better algorithm that improves the
performance by skipping unnecessary steps.

PR-URL: #20961
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@rvagg rvagg mentioned this pull request Aug 13, 2018
Release proposal: v10.9.0 #22295
Merged
This was referenced Aug 16, 2018
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#230
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#215
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#231
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#216
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#232
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#217
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#233
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#218
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#234
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#219
Closed
@targos targos removed the backport-requested-v10.x label Aug 19, 2018
@BridgeAR
BridgeAR deleted the improve-util-inspect-output branch January 20, 2020 11:34
firass111 pushed a commit to firass111/Project_node1 that referenced this pull request Apr 16, 2025
@BridgeAR @rvagg
util: improve display of iterators and weak entries
b171fa2
This adds the number of not visible elements when inspecting iterators
while exceeding `maxArrayLength`.
It also fixes a edge case with `maxArrayLength` and the map.entries()
iterator. Now the whole entry will be visible instead of only the key
but not the value of the first entry.
Besides that it uses a slighly better algorithm that improves the
performance by skipping unnecessary steps.

PR-URL: nodejs/node#20961
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@addaleax addaleax addaleax approved these changes
@TimothyGu TimothyGu Awaiting requested review from TimothyGu

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. console Issues and PRs related to the console subsystem. util Issues and PRs related to the built-in util module.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@BridgeAR @TimothyGu @targos @mcollina @addaleax @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.