mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 07:22:21 +00:00
LibWeb: Add a 'piped through' helper method on ReadableStream
This reads a bit nicer, and follows the streams spec pattern on performing operations on a stream outside of the streams spec.
This commit is contained in:
parent
79a2b96d1c
commit
da408cb09a
Notes:
github-actions[bot]
2024-12-25 11:03:22 +00:00
Author: https://github.com/shannonbooth
Commit: da408cb09a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3029
Reviewed-by: https://github.com/kennethmyhra ✅
5 changed files with 22 additions and 6 deletions
|
@ -290,7 +290,7 @@ bool readable_stream_has_default_reader(ReadableStream const& stream)
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#readable-stream-pipe-to
|
||||
GC::Ref<WebIDL::Promise> readable_stream_pipe_to(ReadableStream& source, WritableStream& dest, bool, bool, bool, Optional<JS::Value> signal)
|
||||
GC::Ref<WebIDL::Promise> readable_stream_pipe_to(ReadableStream& source, WritableStream& dest, bool, bool, bool, JS::Value signal)
|
||||
{
|
||||
auto& realm = source.realm();
|
||||
|
||||
|
@ -299,11 +299,10 @@ GC::Ref<WebIDL::Promise> readable_stream_pipe_to(ReadableStream& source, Writabl
|
|||
// 3. Assert: preventClose, preventAbort, and preventCancel are all booleans.
|
||||
|
||||
// 4. If signal was not given, let signal be undefined.
|
||||
if (!signal.has_value())
|
||||
signal = JS::js_undefined();
|
||||
// NOTE: Done by default argument
|
||||
|
||||
// 5. Assert: either signal is undefined, or signal implements AbortSignal.
|
||||
VERIFY(signal->is_undefined() || (signal->is_object() && is<DOM::AbortSignal>(signal->as_object())));
|
||||
VERIFY(signal.is_undefined() || (signal.is_object() && is<DOM::AbortSignal>(signal.as_object())));
|
||||
|
||||
// 6. Assert: ! IsReadableStreamLocked(source) is false.
|
||||
VERIFY(!is_readable_stream_locked(source));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue