mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:28:11 +00:00
LibWeb: Implement the Streams SetUpReadableStreamBYOBReader AO
Co-Authored-By: Matthew Olsson <mattco@serenityos.org>
This commit is contained in:
parent
aff38ae80f
commit
9ccadf61a2
2 changed files with 21 additions and 0 deletions
|
@ -481,6 +481,26 @@ WebIDL::ExceptionOr<void> set_up_readable_stream_default_reader(ReadableStreamDe
|
|||
return {};
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#set-up-readable-stream-byob-reader
|
||||
WebIDL::ExceptionOr<void> set_up_readable_stream_byob_reader(ReadableStreamBYOBReader& reader, ReadableStream& stream)
|
||||
{
|
||||
// 1. If ! IsReadableStreamLocked(stream) is true, throw a TypeError exception.
|
||||
if (is_readable_stream_locked(stream))
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Cannot create stream reader for a locked stream"sv };
|
||||
|
||||
// 2. If stream.[[controller]] does not implement ReadableByteStreamController, throw a TypeError exception.
|
||||
if (!stream.controller()->has<JS::NonnullGCPtr<ReadableByteStreamController>>())
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "BYOB reader cannot set up reader from non-byte stream"sv };
|
||||
|
||||
// 3. Perform ! ReadableStreamReaderGenericInitialize(reader, stream).
|
||||
readable_stream_reader_generic_initialize(ReadableStreamReader { reader }, stream);
|
||||
|
||||
// 4. Set reader.[[readIntoRequests]] to a new empty list.
|
||||
reader.read_into_requests().clear();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#readable-stream-default-controller-close
|
||||
void readable_stream_default_controller_close(ReadableStreamDefaultController& controller)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue