mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
LibWeb: Implement Streams AO ExtractSizeAlgorithm(strategy)
This commit is contained in:
parent
060c130c82
commit
33f6e5d516
2 changed files with 15 additions and 0 deletions
|
@ -187,6 +187,20 @@ bool readable_stream_has_default_reader(ReadableStream const& stream)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://streams.spec.whatwg.org/#make-size-algorithm-from-size-function
|
||||||
|
SizeAlgorithm extract_size_algorithm(QueuingStrategy const& strategy)
|
||||||
|
{
|
||||||
|
// 1. If strategy["size"] does not exist, return an algorithm that returns 1.
|
||||||
|
if (!strategy.size)
|
||||||
|
return [](auto const&) { return JS::normal_completion(JS::Value(1)); };
|
||||||
|
|
||||||
|
// 2. Return an algorithm that performs the following steps, taking a chunk argument:
|
||||||
|
return [strategy](auto const& chunk) {
|
||||||
|
// 1. Return the result of invoking strategy["size"] with argument list « chunk ».
|
||||||
|
return WebIDL::invoke_callback(*strategy.size, JS::js_undefined(), chunk);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#validate-and-normalize-high-water-mark
|
// https://streams.spec.whatwg.org/#validate-and-normalize-high-water-mark
|
||||||
WebIDL::ExceptionOr<double> extract_high_water_mark(QueuingStrategy const& strategy, double default_hwm)
|
WebIDL::ExceptionOr<double> extract_high_water_mark(QueuingStrategy const& strategy, double default_hwm)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,7 @@ using WriteAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::NonnullGCPtr<Web
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStreamDefaultReader>> acquire_readable_stream_default_reader(ReadableStream&);
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStreamDefaultReader>> acquire_readable_stream_default_reader(ReadableStream&);
|
||||||
bool is_readable_stream_locked(ReadableStream const&);
|
bool is_readable_stream_locked(ReadableStream const&);
|
||||||
|
|
||||||
|
SizeAlgorithm extract_size_algorithm(QueuingStrategy const&);
|
||||||
WebIDL::ExceptionOr<double> extract_high_water_mark(QueuingStrategy const&, double default_hwm);
|
WebIDL::ExceptionOr<double> extract_high_water_mark(QueuingStrategy const&, double default_hwm);
|
||||||
|
|
||||||
void readable_stream_close(ReadableStream&);
|
void readable_stream_close(ReadableStream&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue