/* * Copyright (c) 2020, Matthew Olsson * Copyright (c) 2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace JS { // 7.4 Operations on Iterator Objects, https://tc39.es/ecma262/#sec-operations-on-iterator-objects enum class IteratorHint { Sync, Async, }; ThrowCompletionOr get_iterator(GlobalObject&, Value, IteratorHint = IteratorHint::Sync, Optional method = {}); ThrowCompletionOr iterator_next(GlobalObject&, Iterator const&, Optional = {}); ThrowCompletionOr iterator_step(GlobalObject&, Iterator const&); ThrowCompletionOr iterator_complete(GlobalObject&, Object& iterator_result); ThrowCompletionOr iterator_value(GlobalObject&, Object& iterator_result); Completion iterator_close(GlobalObject&, Iterator const&, Completion); Completion async_iterator_close(GlobalObject&, Iterator const&, Completion); Object* create_iterator_result_object(GlobalObject&, Value, bool done); ThrowCompletionOr> iterable_to_list(GlobalObject&, Value iterable, Optional method = {}); using IteratorValueCallback = Function(Value)>; Completion get_iterator_values(GlobalObject&, Value iterable, IteratorValueCallback callback, Optional method = {}); }