mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00
LibJS: Convert default_number_option() to ThrowCompletionOr
This commit is contained in:
parent
b9c7a629f8
commit
6d3de03549
3 changed files with 20 additions and 18 deletions
|
@ -282,14 +282,16 @@ void set_number_format_digit_options(GlobalObject& global_object, NumberFormat&
|
|||
intl_object.set_rounding_type(NumberFormat::RoundingType::SignificantDigits);
|
||||
|
||||
// b. Let mnsd be ? DefaultNumberOption(mnsd, 1, 21, 1).
|
||||
auto min_digits = default_number_option(global_object, min_significant_digits, 1, 21, 1);
|
||||
if (vm.exception())
|
||||
auto min_digits_or_error = default_number_option(global_object, min_significant_digits, 1, 21, 1);
|
||||
if (min_digits_or_error.is_error())
|
||||
return;
|
||||
auto min_digits = min_digits_or_error.release_value();
|
||||
|
||||
// c. Let mxsd be ? DefaultNumberOption(mxsd, mnsd, 21, 21).
|
||||
auto max_digits = default_number_option(global_object, max_significant_digits, *min_digits, 21, 21);
|
||||
if (vm.exception())
|
||||
auto max_digits_or_error = default_number_option(global_object, max_significant_digits, *min_digits, 21, 21);
|
||||
if (max_digits_or_error.is_error())
|
||||
return;
|
||||
auto max_digits = max_digits_or_error.release_value();
|
||||
|
||||
// d. Set intlObj.[[MinimumSignificantDigits]] to mnsd.
|
||||
intl_object.set_min_significant_digits(*min_digits);
|
||||
|
@ -303,14 +305,16 @@ void set_number_format_digit_options(GlobalObject& global_object, NumberFormat&
|
|||
intl_object.set_rounding_type(NumberFormat::RoundingType::FractionDigits);
|
||||
|
||||
// b. Let mnfd be ? DefaultNumberOption(mnfd, 0, 20, undefined).
|
||||
auto min_digits = default_number_option(global_object, min_fraction_digits, 0, 20, {});
|
||||
if (vm.exception())
|
||||
auto min_digits_or_error = default_number_option(global_object, min_fraction_digits, 0, 20, {});
|
||||
if (min_digits_or_error.is_error())
|
||||
return;
|
||||
auto min_digits = min_digits_or_error.release_value();
|
||||
|
||||
// c. Let mxfd be ? DefaultNumberOption(mxfd, 0, 20, undefined).
|
||||
auto max_digits = default_number_option(global_object, max_fraction_digits, 0, 20, {});
|
||||
if (vm.exception())
|
||||
auto max_digits_or_error = default_number_option(global_object, max_fraction_digits, 0, 20, {});
|
||||
if (max_digits_or_error.is_error())
|
||||
return;
|
||||
auto max_digits = max_digits_or_error.release_value();
|
||||
|
||||
// d. If mnfd is undefined, set mnfd to min(mnfdDefault, mxfd).
|
||||
if (!min_digits.has_value()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue