mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibJS: Convert supported_locales() to ThrowCompletionOr
This commit is contained in:
parent
de9785b71b
commit
d0e5fc4576
5 changed files with 6 additions and 6 deletions
|
@ -568,7 +568,7 @@ Vector<String> best_fit_supported_locales(Vector<String> const& requested_locale
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9.2.10 SupportedLocales ( availableLocales, requestedLocales, options ), https://tc39.es/ecma402/#sec-supportedlocales
|
// 9.2.10 SupportedLocales ( availableLocales, requestedLocales, options ), https://tc39.es/ecma402/#sec-supportedlocales
|
||||||
Array* supported_locales(GlobalObject& global_object, Vector<String> const& requested_locales, Value options)
|
ThrowCompletionOr<Array*> supported_locales(GlobalObject& global_object, Vector<String> const& requested_locales, Value options)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
|
@ -578,7 +578,7 @@ Array* supported_locales(GlobalObject& global_object, Vector<String> const& requ
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
// 2. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
|
// 2. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
|
||||||
auto matcher = TRY_OR_DISCARD(get_option(global_object, *options_object, vm.names.localeMatcher, Value::Type::String, { "lookup"sv, "best fit"sv }, "best fit"sv));
|
auto matcher = TRY(get_option(global_object, *options_object, vm.names.localeMatcher, Value::Type::String, { "lookup"sv, "best fit"sv }, "best fit"sv));
|
||||||
|
|
||||||
Vector<String> supported_locales;
|
Vector<String> supported_locales;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ String insert_unicode_extension_and_canonicalize(Unicode::LocaleID locale_id, Un
|
||||||
LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptions const& options, Vector<StringView> const& relevant_extension_keys);
|
LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptions const& options, Vector<StringView> const& relevant_extension_keys);
|
||||||
Vector<String> lookup_supported_locales(Vector<String> const& requested_locales);
|
Vector<String> lookup_supported_locales(Vector<String> const& requested_locales);
|
||||||
Vector<String> best_fit_supported_locales(Vector<String> const& requested_locales);
|
Vector<String> best_fit_supported_locales(Vector<String> const& requested_locales);
|
||||||
Array* supported_locales(GlobalObject&, Vector<String> const& requested_locales, Value options);
|
ThrowCompletionOr<Array*> supported_locales(GlobalObject&, Vector<String> const& requested_locales, Value options);
|
||||||
Object* coerce_options_to_object(GlobalObject& global_object, Value options);
|
Object* coerce_options_to_object(GlobalObject& global_object, Value options);
|
||||||
ThrowCompletionOr<Value> get_option(GlobalObject& global_object, Object const& options, PropertyName const& property, Value::Type type, Vector<StringView> const& values, Fallback fallback);
|
ThrowCompletionOr<Value> get_option(GlobalObject& global_object, Object const& options, PropertyName const& property, Value::Type type, Vector<StringView> const& values, Fallback fallback);
|
||||||
Optional<int> default_number_option(GlobalObject& global_object, Value value, int minimum, int maximum, Optional<int> fallback);
|
Optional<int> default_number_option(GlobalObject& global_object, Value value, int minimum, int maximum, Optional<int> fallback);
|
||||||
|
|
|
@ -131,7 +131,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesConstructor::supported_locales_of)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
// 3. Return ? SupportedLocales(availableLocales, requestedLocales, options).
|
// 3. Return ? SupportedLocales(availableLocales, requestedLocales, options).
|
||||||
return supported_locales(global_object, requested_locales, options);
|
return TRY_OR_DISCARD(supported_locales(global_object, requested_locales, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatConstructor::supported_locales_of)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
// 3. Return ? SupportedLocales(availableLocales, requestedLocales, options).
|
// 3. Return ? SupportedLocales(availableLocales, requestedLocales, options).
|
||||||
return supported_locales(global_object, requested_locales, options);
|
return TRY_OR_DISCARD(supported_locales(global_object, requested_locales, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatConstructor::supported_locales_of)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
// 3. Return ? SupportedLocales(availableLocales, requestedLocales, options).
|
// 3. Return ? SupportedLocales(availableLocales, requestedLocales, options).
|
||||||
return supported_locales(global_object, requested_locales, options);
|
return TRY_OR_DISCARD(supported_locales(global_object, requested_locales, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue