summaryrefslogtreecommitdiff
path: root/src/node_util.cc
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 /src/node_util.cc
parentcaf2335a47db089a1e1b2c5a90d85cf644f6c355 (diff)
downloadandroid-node-v8-81bc23fe61994784de270d5fc01bc5315dfa62f3.tar.gz
android-node-v8-81bc23fe61994784de270d5fc01bc5315dfa62f3.tar.bz2
android-node-v8-81bc23fe61994784de270d5fc01bc5315dfa62f3.zip
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 'src/node_util.cc')
-rw-r--r--src/node_util.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/node_util.cc b/src/node_util.cc
index 9f31786b32..41b1307bb4 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -57,6 +57,9 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
Local<Array> entries;
if (!args[0].As<Object>()->PreviewEntries(&is_key_value).ToLocal(&entries))
return;
+ // Fast path for WeakMap, WeakSet and Set iterators.
+ if (args.Length() == 1)
+ return args.GetReturnValue().Set(entries);
Local<Array> ret = Array::New(env->isolate(), 2);
ret->Set(env->context(), 0, entries).FromJust();
ret->Set(env->context(), 1, v8::Boolean::New(env->isolate(), is_key_value))