From 7cf3f11815b08d4d336d41cca16f930fd68e9c88 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 29 Jan 2022 23:50:40 +0200 Subject: [PATCH] js: Implement pretty-printing of Intl.Segmenter --- Userland/Utilities/js.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 #include #include +#include #include #include #include @@ -830,6 +831,16 @@ static void print_intl_collator(JS::Object const& object, HashTable print_value(JS::Value(collator.numeric()), seen_objects); } +static void print_intl_segmenter(JS::Object const& object, HashTable& seen_objects) +{ + auto& segmenter = static_cast(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& seen_objects) { // BooleanObject, NumberObject, StringObject @@ -931,6 +942,8 @@ static void print_value(JS::Value value, HashTable& seen_objects) return print_intl_plural_rules(object, seen_objects); if (is(object)) return print_intl_collator(object, seen_objects); + if (is(object)) + return print_intl_segmenter(object, seen_objects); return print_object(object, seen_objects); }