From dee8e53773ee583008971faf1c2a31da2b3f27c7 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 30 Jun 2022 20:00:00 +0100 Subject: [PATCH] js: Implement pretty-printing of WeakSet objects --- Userland/Utilities/js.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 #include #include +#include #include #include #include @@ -421,6 +422,13 @@ static void print_weak_map(JS::WeakMap const& weak_map, HashTable&) // 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&) +{ + 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& seen_objects) { print_type("Promise"); @@ -992,6 +1000,8 @@ static void print_value(JS::Value value, HashTable& seen_objects) 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_weak_set(static_cast(object), seen_objects); if (is(object)) return print_data_view(static_cast(object), seen_objects); if (is(object))