mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
LibWeb: Add AO transform_stream_default_controller_perform_transform()
This commit is contained in:
parent
4d4fc53f5c
commit
11c0600729
2 changed files with 23 additions and 0 deletions
|
@ -2823,6 +2823,28 @@ WebIDL::ExceptionOr<void> transform_stream_default_controller_terminate(Transfor
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://streams.spec.whatwg.org/#transform-stream-default-controller-perform-transform
|
||||||
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> transform_stream_default_controller_perform_transform(TransformStreamDefaultController& controller, JS::Value chunk)
|
||||||
|
{
|
||||||
|
auto& realm = controller.realm();
|
||||||
|
|
||||||
|
// 1. Let transformPromise be the result of performing controller.[[transformAlgorithm]], passing chunk.
|
||||||
|
auto transform_promise = TRY((*controller.transform_algorithm())(chunk));
|
||||||
|
|
||||||
|
// 2. Return the result of reacting to transformPromise with the following rejection steps given the argument r:
|
||||||
|
auto react_result = WebIDL::react_to_promise(*transform_promise,
|
||||||
|
{},
|
||||||
|
[&](auto const& reason) -> WebIDL::ExceptionOr<JS::Value> {
|
||||||
|
// 1. Perform ! TransformStreamError(controller.[[stream]], r).
|
||||||
|
TRY(transform_stream_error(*controller.stream(), reason));
|
||||||
|
|
||||||
|
// 2. Throw r.
|
||||||
|
return JS::throw_completion(reason);
|
||||||
|
});
|
||||||
|
|
||||||
|
return WebIDL::create_resolved_promise(realm, react_result);
|
||||||
|
}
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#transform-stream-error
|
// https://streams.spec.whatwg.org/#transform-stream-error
|
||||||
WebIDL::ExceptionOr<void> transform_stream_error(TransformStream& stream, JS::Value error)
|
WebIDL::ExceptionOr<void> transform_stream_error(TransformStream& stream, JS::Value error)
|
||||||
{
|
{
|
||||||
|
|
|
@ -137,6 +137,7 @@ void transform_stream_default_controller_clear_algorithms(TransformStreamDefault
|
||||||
WebIDL::ExceptionOr<void> transform_stream_default_controller_enqueue(TransformStreamDefaultController&, JS::Value chunk);
|
WebIDL::ExceptionOr<void> transform_stream_default_controller_enqueue(TransformStreamDefaultController&, JS::Value chunk);
|
||||||
WebIDL::ExceptionOr<void> transform_stream_default_controller_error(TransformStreamDefaultController&, JS::Value error);
|
WebIDL::ExceptionOr<void> transform_stream_default_controller_error(TransformStreamDefaultController&, JS::Value error);
|
||||||
WebIDL::ExceptionOr<void> transform_stream_default_controller_terminate(TransformStreamDefaultController&);
|
WebIDL::ExceptionOr<void> transform_stream_default_controller_terminate(TransformStreamDefaultController&);
|
||||||
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> transform_stream_default_controller_perform_transform(TransformStreamDefaultController&, JS::Value chunk);
|
||||||
WebIDL::ExceptionOr<void> transform_stream_error(TransformStream&, JS::Value error);
|
WebIDL::ExceptionOr<void> transform_stream_error(TransformStream&, JS::Value error);
|
||||||
WebIDL::ExceptionOr<void> transform_stream_error_writable_and_unblock_write(TransformStream&, JS::Value error);
|
WebIDL::ExceptionOr<void> transform_stream_error_writable_and_unblock_write(TransformStream&, JS::Value error);
|
||||||
WebIDL::ExceptionOr<void> transform_stream_set_backpressure(TransformStream&, bool backpressure);
|
WebIDL::ExceptionOr<void> transform_stream_set_backpressure(TransformStream&, bool backpressure);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue