mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:57:44 +00:00
LibJS: Convert IteratorComplete AO to ThrowCompletionOr
This commit is contained in:
parent
8be1caa05d
commit
a64752cd34
4 changed files with 15 additions and 13 deletions
|
@ -57,12 +57,12 @@ ThrowCompletionOr<Object*> iterator_next(Object& iterator, Value value)
|
|||
}
|
||||
|
||||
// 7.4.3 IteratorComplete ( iterResult ), https://tc39.es/ecma262/#sec-iteratorcomplete
|
||||
bool iterator_complete(GlobalObject& global_object, Object& iterator_result)
|
||||
ThrowCompletionOr<bool> iterator_complete(GlobalObject& global_object, Object& iterator_result)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 1. Return ! ToBoolean(? Get(iterResult, "done")).
|
||||
return TRY_OR_DISCARD(iterator_result.get(vm.names.done)).to_boolean();
|
||||
return TRY(iterator_result.get(vm.names.done)).to_boolean();
|
||||
}
|
||||
|
||||
// 7.4.4 IteratorValue ( iterResult ), https://tc39.es/ecma262/#sec-iteratorvalue
|
||||
|
@ -77,13 +77,8 @@ Value iterator_value(GlobalObject& global_object, Object& iterator_result)
|
|||
// 7.4.5 IteratorStep ( iteratorRecord ), https://tc39.es/ecma262/#sec-iteratorstep
|
||||
ThrowCompletionOr<Object*> iterator_step(GlobalObject& global_object, Object& iterator)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
auto* result = TRY(iterator_next(iterator));
|
||||
|
||||
auto done = iterator_complete(global_object, *result);
|
||||
if (auto* exception = vm.exception())
|
||||
return throw_completion(exception->value());
|
||||
auto done = TRY(iterator_complete(global_object, *result));
|
||||
|
||||
if (done)
|
||||
return nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue