/* * Copyright (c) 2020, Matthew Olsson * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #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 value, IteratorHint hint = IteratorHint::Sync, Value method = {}); ThrowCompletionOr iterator_next(Object& iterator, Value value = {}); ThrowCompletionOr iterator_step(GlobalObject&, Object& iterator); ThrowCompletionOr iterator_complete(GlobalObject&, Object& iterator_result); ThrowCompletionOr iterator_value(GlobalObject&, Object& iterator_result); Completion iterator_close(Object& iterator, Completion completion); Object* create_iterator_result_object(GlobalObject&, Value value, bool done); ThrowCompletionOr iterable_to_list(GlobalObject&, Value iterable, Value method = {}); using IteratorValueCallback = Function(Value)>; Completion get_iterator_values(GlobalObject& global_object, Value iterable, IteratorValueCallback callback, Value method = {}); }