diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2022-01-29 23:50:40 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-30 19:47:01 +0000 |
commit | 7cf3f11815b08d4d336d41cca16f930fd68e9c88 (patch) | |
tree | 562e315c964c91a592a7d48746ae6d0acd02c1b8 /Userland/Utilities | |
parent | a3bc06bb23910cf3bcfe8965fdefea5aff713e4a (diff) | |
download | serenity-7cf3f11815b08d4d336d41cca16f930fd68e9c88.zip |
js: Implement pretty-printing of Intl.Segmenter
Diffstat (limited to 'Userland/Utilities')
-rw-r--r-- | Userland/Utilities/js.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 9bb295fc12..8dc6ec60c0 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -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); } |