mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:57:42 +00:00
js: Implement pretty-printing of Intl.Segmenter
This commit is contained in:
parent
a3bc06bb23
commit
7cf3f11815
1 changed files with 13 additions and 0 deletions
|
@ -40,6 +40,7 @@
|
|||
#include <LibJS/Runtime/Intl/NumberFormat.h>
|
||||
#include <LibJS/Runtime/Intl/PluralRules.h>
|
||||
#include <LibJS/Runtime/Intl/RelativeTimeFormat.h>
|
||||
#include <LibJS/Runtime/Intl/Segmenter.h>
|
||||
#include <LibJS/Runtime/JSONObject.h>
|
||||
#include <LibJS/Runtime/Map.h>
|
||||
#include <LibJS/Runtime/NativeFunction.h>
|
||||
|
@ -830,6 +831,16 @@ static void print_intl_collator(JS::Object const& object, HashTable<JS::Object*>
|
|||
print_value(JS::Value(collator.numeric()), seen_objects);
|
||||
}
|
||||
|
||||
static void print_intl_segmenter(JS::Object const& object, HashTable<JS::Object*>& seen_objects)
|
||||
{
|
||||
auto& segmenter = static_cast<JS::Intl::Segmenter const&>(object);
|
||||
print_type("Intl.Segmenter");
|
||||
out("\n locale: ");
|
||||
print_value(js_string(object.vm(), segmenter.locale()), seen_objects);
|
||||
out("\n granularity: ");
|
||||
print_value(js_string(object.vm(), segmenter.segmenter_granularity_string()), seen_objects);
|
||||
}
|
||||
|
||||
static void print_primitive_wrapper_object(FlyString const& name, JS::Object const& object, HashTable<JS::Object*>& seen_objects)
|
||||
{
|
||||
// BooleanObject, NumberObject, StringObject
|
||||
|
@ -931,6 +942,8 @@ static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects)
|
|||
return print_intl_plural_rules(object, seen_objects);
|
||||
if (is<JS::Intl::Collator>(object))
|
||||
return print_intl_collator(object, seen_objects);
|
||||
if (is<JS::Intl::Segmenter>(object))
|
||||
return print_intl_segmenter(object, seen_objects);
|
||||
return print_object(object, seen_objects);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue