summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-06-30 19:59:24 +0100
committerLinus Groh <mail@linusgroh.de>2022-07-01 00:13:21 +0100
commit28e184e5ccf0dc322d329b82cc002b7e5f1e9a6b (patch)
tree3023a163d38a608c431d55aa806efd71850ac572 /Userland/Utilities
parent18f27c2e6433a1342d76c6b6703441ee37fd2328 (diff)
downloadserenity-28e184e5ccf0dc322d329b82cc002b7e5f1e9a6b.zip
js: Implement pretty-printing of WeakMap objects
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/js.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 1ceda2b5ef..ff6525b7d0 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -72,6 +72,7 @@
#include <LibJS/Runtime/Temporal/ZonedDateTime.h>
#include <LibJS/Runtime/TypedArray.h>
#include <LibJS/Runtime/Value.h>
+#include <LibJS/Runtime/WeakMap.h>
#include <LibJS/SourceTextModule.h>
#include <LibLine/Editor.h>
#include <LibMain/Main.h>
@@ -413,6 +414,13 @@ static void print_set(JS::Set const& set, HashTable<JS::Object*>& seen_objects)
js_out("}}");
}
+static void print_weak_map(JS::WeakMap const& weak_map, HashTable<JS::Object*>&)
+{
+ print_type("WeakMap");
+ js_out(" ({})", weak_map.values().size());
+ // Note: We could tell you what's actually inside, but not in insertion order.
+}
+
static void print_promise(JS::Promise const& promise, HashTable<JS::Object*>& seen_objects)
{
print_type("Promise");
@@ -982,6 +990,8 @@ static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects)
return print_map(static_cast<JS::Map&>(object), seen_objects);
if (is<JS::Set>(object))
return print_set(static_cast<JS::Set&>(object), seen_objects);
+ if (is<JS::WeakMap>(object))
+ return print_weak_map(static_cast<JS::WeakMap&>(object), seen_objects);
if (is<JS::DataView>(object))
return print_data_view(static_cast<JS::DataView&>(object), seen_objects);
if (is<JS::ProxyObject>(object))