From 28e184e5ccf0dc322d329b82cc002b7e5f1e9a6b Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 30 Jun 2022 19:59:24 +0100 Subject: js: Implement pretty-printing of WeakMap objects --- Userland/Utilities/js.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Userland/Utilities') 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 #include #include +#include #include #include #include @@ -413,6 +414,13 @@ static void print_set(JS::Set const& set, HashTable& seen_objects) js_out("}}"); } +static void print_weak_map(JS::WeakMap const& weak_map, HashTable&) +{ + 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& seen_objects) { print_type("Promise"); @@ -982,6 +990,8 @@ static void print_value(JS::Value value, HashTable& seen_objects) return print_map(static_cast(object), seen_objects); if (is(object)) return print_set(static_cast(object), seen_objects); + if (is(object)) + return print_weak_map(static_cast(object), seen_objects); if (is(object)) return print_data_view(static_cast(object), seen_objects); if (is(object)) -- cgit v1.2.3