mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 02:38:13 +00:00
LibJS: Convert get_number_option() to ThrowCompletionOr
This commit is contained in:
parent
6d3de03549
commit
407cf04884
3 changed files with 8 additions and 7 deletions
|
@ -683,18 +683,18 @@ ThrowCompletionOr<Optional<int>> default_number_option(GlobalObject& global_obje
|
|||
}
|
||||
|
||||
// 9.2.15 GetNumberOption ( options, property, minimum, maximum, fallback ), https://tc39.es/ecma402/#sec-getnumberoption
|
||||
Optional<int> get_number_option(GlobalObject& global_object, Object const& options, PropertyName const& property, int minimum, int maximum, Optional<int> fallback)
|
||||
ThrowCompletionOr<Optional<int>> get_number_option(GlobalObject& global_object, Object const& options, PropertyName const& property, int minimum, int maximum, Optional<int> fallback)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 1. Assert: Type(options) is Object.
|
||||
// 2. Let value be ? Get(options, property).
|
||||
auto value = options.get(property);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (auto* exception = vm.exception())
|
||||
return throw_completion(exception->value());
|
||||
|
||||
// 3. Return ? DefaultNumberOption(value, minimum, maximum, fallback).
|
||||
return TRY_OR_DISCARD(default_number_option(global_object, value, minimum, maximum, move(fallback)));
|
||||
return default_number_option(global_object, value, minimum, maximum, move(fallback));
|
||||
}
|
||||
|
||||
// 9.2.16 PartitionPattern ( pattern ), https://tc39.es/ecma402/#sec-partitionpattern
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue