mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
js: Implement pretty-printing of WeakMap objects
This commit is contained in:
parent
18f27c2e64
commit
28e184e5cc
1 changed files with 10 additions and 0 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue