summaryrefslogtreecommitdiff
path: root/lib/console.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-05-25 12:05:39 +0200
committerRuben Bridgewater <ruben@bridgewater.de>2018-07-18 17:21:14 +0200
commit81bc23fe61994784de270d5fc01bc5315dfa62f3 (patch)
tree9779397ab7a26019bd44844d5cf11e023a00ea32 /lib/console.js
parentcaf2335a47db089a1e1b2c5a90d85cf644f6c355 (diff)
downloadnode-new-81bc23fe61994784de270d5fc01bc5315dfa62f3.tar.gz
util: improve display of iterators and weak entries
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: https://github.com/nodejs/node/pull/20961 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/console.js')
-rw-r--r--lib/console.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/console.js b/lib/console.js
index 665a2a6a23..a5b2265f58 100644
--- a/lib/console.js
+++ b/lib/console.js
@@ -367,8 +367,11 @@ Console.prototype.table = function(tabularData, properties) {
const mapIter = isMapIterator(tabularData);
let isKeyValue = false;
let i = 0;
- if (mapIter)
- [ tabularData, isKeyValue ] = previewEntries(tabularData);
+ if (mapIter) {
+ const res = previewEntries(tabularData, true);
+ tabularData = res[0];
+ isKeyValue = res[1];
+ }
if (isKeyValue || isMap(tabularData)) {
const keys = [];
@@ -398,7 +401,7 @@ Console.prototype.table = function(tabularData, properties) {
const setIter = isSetIterator(tabularData);
if (setIter)
- [ tabularData ] = previewEntries(tabularData);
+ tabularData = previewEntries(tabularData);
const setlike = setIter || (mapIter && !isKeyValue) || isSet(tabularData);
if (setlike) {