2020-07-09 18:58:20 -03:00
|
|
|
/*
|
2021-04-22 20:53:07 -03:00
|
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
2020-07-09 18:58:20 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-09 18:58:20 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-07-13 12:27:20 -03:00
|
|
|
#include <AK/Function.h>
|
2020-07-09 18:58:20 -03:00
|
|
|
#include <LibJS/Runtime/Object.h>
|
|
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
2021-06-12 20:22:35 -03:00
|
|
|
// 7.4 Operations on Iterator Objects, https://tc39.es/ecma262/#sec-operations-on-iterator-objects
|
2020-07-09 18:58:20 -03:00
|
|
|
|
2021-06-02 16:52:46 -03:00
|
|
|
enum class IteratorHint {
|
|
|
|
|
Sync,
|
|
|
|
|
Async,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Object* get_iterator(GlobalObject&, Value value, IteratorHint hint = IteratorHint::Sync, Value method = {});
|
2020-07-13 12:27:20 -03:00
|
|
|
Object* iterator_next(Object& iterator, Value value = {});
|
2021-07-03 19:33:37 -03:00
|
|
|
Object* iterator_step(GlobalObject&, Object& iterator);
|
2021-06-13 17:39:46 -03:00
|
|
|
bool iterator_complete(GlobalObject&, Object& iterator_result);
|
|
|
|
|
Value iterator_value(GlobalObject&, Object& iterator_result);
|
2020-07-09 18:58:20 -03:00
|
|
|
void iterator_close(Object& iterator);
|
2021-06-13 17:39:46 -03:00
|
|
|
Value create_iterator_result_object(GlobalObject&, Value value, bool done);
|
2021-04-16 17:54:41 -03:00
|
|
|
MarkedValueList iterable_to_list(GlobalObject&, Value iterable, Value method = {});
|
|
|
|
|
|
2021-06-14 07:46:02 -03:00
|
|
|
enum class CloseOnAbrupt {
|
|
|
|
|
No,
|
|
|
|
|
Yes
|
|
|
|
|
};
|
2021-06-27 17:38:42 -03:00
|
|
|
void get_iterator_values(GlobalObject&, Value value, Function<IterationDecision(Value)> callback, Value method = {}, CloseOnAbrupt close_on_abrupt = CloseOnAbrupt::Yes);
|
2020-07-13 12:27:20 -03:00
|
|
|
|
2020-07-09 18:58:20 -03:00
|
|
|
}
|