mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-27 13:32:52 +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
|
@ -383,4 +383,20 @@ void ReadableStream::set_up_with_byte_reading_support(GC::Ptr<PullAlgorithm> pul
|
|||
MUST(set_up_readable_byte_stream_controller(*this, controller, start_algorithm, pull_algorithm_wrapper, cancel_algorithm_wrapper, high_water_mark, JS::js_undefined()));
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#readablestream-pipe-through
|
||||
GC::Ref<WebIDL::Promise> ReadableStream::piped_through(GC::Ref<WritableStream> writable, bool prevent_close, bool prevent_abort, bool prevent_cancel, JS::Value signal)
|
||||
{
|
||||
// 1. Assert: ! IsReadableStreamLocked(readable) is false.
|
||||
VERIFY(!is_readable_stream_locked(*this));
|
||||
|
||||
// 2. Assert: ! IsWritableStreamLocked(writable) is false.
|
||||
VERIFY(!is_writable_stream_locked(writable));
|
||||
|
||||
// 3. Let signalArg be signal if signal was given, or undefined otherwise.
|
||||
// NOTE: Done by default arguments.
|
||||
|
||||
// 4. Return ! ReadableStreamPipeTo(readable, writable, preventClose, preventAbort, preventCancel, signalArg).
|
||||
return readable_stream_pipe_to(*this, writable, prevent_close, prevent_abort, prevent_cancel, signal);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue