diff options
author | Linus Groh <mail@linusgroh.de> | 2022-06-30 20:00:00 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-07-01 00:13:21 +0100 |
commit | dee8e53773ee583008971faf1c2a31da2b3f27c7 (patch) | |
tree | 316ea6622eed62a313ea8dffb408587c5d8d67ba /Userland | |
parent | 28e184e5ccf0dc322d329b82cc002b7e5f1e9a6b (diff) | |
download | serenity-dee8e53773ee583008971faf1c2a31da2b3f27c7.zip |
js: Implement pretty-printing of WeakSet objects
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Utilities/js.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index ff6525b7d0..afa44cdfbe 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -73,6 +73,7 @@ #include <LibJS/Runtime/TypedArray.h> #include <LibJS/Runtime/Value.h> #include <LibJS/Runtime/WeakMap.h> +#include <LibJS/Runtime/WeakSet.h> #include <LibJS/SourceTextModule.h> #include <LibLine/Editor.h> #include <LibMain/Main.h> @@ -421,6 +422,13 @@ static void print_weak_map(JS::WeakMap const& weak_map, HashTable<JS::Object*>&) // Note: We could tell you what's actually inside, but not in insertion order. } +static void print_weak_set(JS::WeakSet const& weak_set, HashTable<JS::Object*>&) +{ + print_type("WeakSet"); + js_out(" ({})", weak_set.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"); @@ -992,6 +1000,8 @@ static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects) 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::WeakSet>(object)) + return print_weak_set(static_cast<JS::WeakSet&>(object), seen_objects); if (is<JS::DataView>(object)) return print_data_view(static_cast<JS::DataView&>(object), seen_objects); if (is<JS::ProxyObject>(object)) |