/* * Copyright (c) 2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::Streams { // https://streams.spec.whatwg.org/#dictdef-readablestreamiteratoroptions struct ReadableStreamIteratorOptions { bool prevent_cancel { false }; }; class ReadableStreamAsyncIterator final : public WebIDL::AsyncIterator { WEB_PLATFORM_OBJECT(ReadableStreamAsyncIterator, WebIDL::AsyncIterator); GC_DECLARE_ALLOCATOR(ReadableStreamAsyncIterator); public: static WebIDL::ExceptionOr> create(JS::Realm&, JS::Object::PropertyKind, ReadableStream&, ReadableStreamIteratorOptions); virtual ~ReadableStreamAsyncIterator() override; private: ReadableStreamAsyncIterator(JS::Realm&, JS::Object::PropertyKind, GC::Ref, bool prevent_cancel); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual GC::Ref next_iteration_result(JS::Realm&) override; virtual GC::Ref iterator_return(JS::Realm&, JS::Value) override; GC::Ref m_reader; bool m_prevent_cancel { false }; }; }