1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

LibWeb: Add ReadableStream.locked/cancel()/getReader()

This commit is contained in:
Matthew Olsson 2023-03-28 20:01:04 -07:00 committed by Linus Groh
parent d8710aa604
commit 36ca1386e8
6 changed files with 63 additions and 1 deletions

View file

@ -20,6 +20,21 @@
namespace Web::Streams {
// https://streams.spec.whatwg.org/#acquire-readable-stream-reader
WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStreamDefaultReader>> acquire_readable_stream_default_reader(ReadableStream& stream)
{
auto& realm = stream.realm();
// 1. Let reader be a new ReadableStreamDefaultReader.
auto reader = TRY(realm.heap().allocate<ReadableStreamDefaultReader>(realm, realm));
// 2. Perform ? SetUpReadableStreamDefaultReader(reader, stream).
TRY(set_up_readable_stream_default_reader(reader, stream));
// 3. Return reader.
return reader;
}
// https://streams.spec.whatwg.org/#is-readable-stream-locked
bool is_readable_stream_locked(ReadableStream const& stream)
{