-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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 Set and Map size to the inspect output #30225
Conversation
9863eb1
to
8d6cd92
Compare
Would it be a bit more intuitive (and more consistent) to handle this like we do for e.g. ArrayBuffers, i.e. print
|
I don't think it's immediately clear what the number on the map means. Can we just show 'size' as a normal property? if someone overrides it they probably would want our inspection to show the overridden one anyway. |
I am fine to print that instead. This implementation is just not possible to manipulate. The other one could show something else (I actually added a test for that). |
Just as a note: I personally think the shorter notation is nicer to read (even though it definitely requires a short moment to understand the number when seeing this notation for the first time). I updated the implementation nevertheless. PTAL. |
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.
I find the brackets around [size]
weird and would recommend to omit them, but either way this LGTM
Outdated due to a changed implementation.
I went ahead and created a twitter pool for this: https://twitter.com/BridgeAR/status/1195687117080408067 Seems like
I therefore went back to my initial implementation. @addaleax I removed your LG due to that change. PTAL @joyeecheung we could in theory only add the number in a couple of cases (depending on the size). Set and Map entries can in general look very different though and in some cases it might be straight forward to see how many entries they are while it's more difficult in other cases. Thus I think it's best to be consistent. Especially as it might also be confusing to some users to see different output depending on the size. @nodejs/util PTAL |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
a9b559d
to
402f9be
Compare
Rebased due to conflicts @nodejs/util this could use some reviews. |
This comment has been minimized.
This comment has been minimized.
I think this can be semver-patch. There are no additions to the public API. |
I am fine with this being a patch as well. We treat most of our util changes as patches. I'll follow your recommendation while I am fine both ways. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
CI: https://ci.nodejs.org/job/node-test-pull-request/27448/ ✅ (yellow build with a known Windows flake) |
Out of caution, here's a CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/2127/ ✔️ |
This removes the special handling to inspect iterable objects with a null prototype. It is now handled together with the regular prototype. PR-URL: #30225 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This adds the size of a set and map to the output. This aligns the output with the one from Chromium. PR-URL: #30225 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This removes the special handling to inspect iterable objects with a null prototype. It is now handled together with the regular prototype. PR-URL: #30225 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This adds the size of a set and map to the output. This aligns the output with the one from Chromium. PR-URL: #30225 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Notable Changes: * cli: * add --trace-exit cli option (legendecas) #30516 * http,https: * increase server headers timeout (Tim Costa) #30071 * readline: * update ansi-regex (Ruben Bridgewater) #30907 * promote \_getCursorPos to public api (Jeremy Albright) #30687 * repl: * add completion preview (Ruben Bridgewater) #30907 * util: * add Set and map size to inspect output (Ruben Bridgewater) #30225 * wasi: * require CLI flag to require() wasi module (Colin Ihrig) #30963 PR-URL: #31010
Notable Changes: * cli: * add --trace-exit cli option (legendecas) #30516 * http,https: * increase server headers timeout (Tim Costa) #30071 * readline: * update ansi-regex (Ruben Bridgewater) #30907 * promote \_getCursorPos to public api (Jeremy Albright) #30687 * repl: * add completion preview (Ruben Bridgewater) #30907 * util: * add Set and map size to inspect output (Ruben Bridgewater) #30225 * wasi: * require CLI flag to require() wasi module (Colin Ihrig) #30963 PR-URL: #31010
This doesn't land cleanly on v12.x-staging and probably depends on previous PRs that were not backported yet. |
This removes the special handling to inspect iterable objects with a null prototype. It is now handled together with the regular prototype. PR-URL: nodejs#30225 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This adds the set or map size while serializing those with
inspect()
.That aligns the output with the one from Chromium. To do so, I refactored some code that special handled iterators that had the prototype set to
null
. That is not required anymore. It was necessary to bind some properties to later on used functions to keep the performance profile in tact and the implementation similar to the way it used to work.Due to the refactoring a few more edge cases will also from now on be handled properly (inspecting a set or map with a broken iterator symbol or the size property manipulated will still work).
This should be semver-minor, since we explicitly note that people should not rely on the inspect output programmatically.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes