Truncate long Set and Map in util.inspect/console.log/REPL, just like long Array #42933
Labels
feature request
Issues that request new features to be added to Node.js.
stale
util
Issues and PRs related to the built-in util module.
What is the problem this feature will solve?
console.log()
,util.inspect()
and REPL prints can become unreadable if you happen to have a very largeSet
orMap
as part of the data you’re passing. But if you have a very largeArray
, the print helpfully cuts off after 100 items (adding something like... 900 more items
at the end).What is the feature you are proposing to solve the problem?
Set
andMap
were added toutil.inspect
: util: support inspecting Map, Set, and Promise #1471maxArrayLength
option (defaulting to 100) was added toutil.inspect
: util: truncate inspect array and typed array #6334maxArrayLength
was extended to also coverWeakSet
andWeakMap
: util: improve Weak(Map|Set) support #19259So
maxArrayLength
covers Array, TypedArray, WeakMap and WeakSet, but not plain Map and Set.In the last PR I linked to above, there was even a TODO comment at one point suggesting to rename
maxArrayLength
tomaxEntries
: #19259 (comment)I suggest that
maxArrayLength
keeps it name (renaming would be another issue), but also applies to Map and Set.What alternatives have you considered?
I could add something like this to my application:
But it feels a bit dirty, and I also seem to lose color that way. I also need to do it in every project, and it’s unclear how to get it into the REPL.
The text was updated successfully, but these errors were encountered: