From 726f4b2a1936ce0680aa59781c7b27f29bc706dc Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Tue, 30 Nov 2021 23:40:30 +0100 Subject: [PATCH] Add HWM and size algorithms to "set up a TransformStream" --- index.bs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/index.bs b/index.bs index 605ebdced..9d5992cd3 100644 --- a/index.bs +++ b/index.bs @@ -6819,7 +6819,7 @@ for="ReadableStream">locked if ! [$IsReadableStreamLocked$](|stream|) retu up">writeAlgorithm, an optional algorithm closeAlgorithm, an optional algorithm abortAlgorithm, an optional number highWaterMark (default 1), an optional algorithm highWaterMark (default 1), and an optional algorithm sizeAlgorithm, perform the following steps. |writeAlgorithm| must be an algorithm that accepts a [=chunk=] object and returns a promise. If given, |closeAlgorithm| and |abortAlgorithm| may return a promise. If given, |sizeAlgorithm| must @@ -6900,14 +6900,22 @@ reason.
To set up a newly-[=new|created-via-Web IDL=] {{TransformStream}} |stream| given an algorithm transformAlgorithm and an optional algorithm flushAlgorithm, perform the following steps. + for="TransformStream/set up">transformAlgorithm, an optional algorithm flushAlgorithm, an optional number writableHighWaterMark (default 1), an optional + algorithm writableSizeAlgorithm, an + optional number readableHighWaterMark + (default 0), and an optional algorithm readableSizeAlgorithm, perform the following steps. |transformAlgorithm| and, if given, |flushAlgorithm|, may return a promise. + If given, |writableSizeAlgorithm| and |readableSizeAlgorithm| must be algorithms accepting + [=chunk=] objects and returning a number; and if given, |writableHighWaterMark| and + |readableHighWaterMark| must be non-negative, non-NaN numbers. - 1. Let |writableHighWaterMark| be 1. - 1. Let |writableSizeAlgorithm| be an algorithm that returns 1. - 1. Let |readableHighWaterMark| be 0. - 1. Let |readableSizeAlgorithm| be an algorithm that returns 1. + 1. If |writableSizeAlgorithm| was not given, let |writableSizeAlgorithm| be an algorithm that + returns 1. + 1. If |readableSizeAlgorithm| was not given, let |readableSizeAlgorithm| be an algorithm that + returns 1. 1. Let |transformAlgorithmWrapper| be an algorithm that runs these steps given a value |chunk|: 1. Let |result| be the result of running |transformAlgorithm| given |chunk|. If this throws an exception |e|, return [=a promise rejected with=] |e|. @@ -6952,7 +6960,7 @@ reason. The following algorithms must only be used on {{TransformStream}} instances initialized via the above [=TransformStream/set up=] algorithm. Usually they are called as part of [=TransformStream/set up/transformAlgorithm=] or -[=TransformStream/set up/flushAlgorithm=]. +[=TransformStream/set up/flushAlgorithm=].

To enqueue the JavaScript value |chunk| into a {{TransformStream}} |stream|, perform ! @@ -6995,8 +7003,7 @@ Including the {{GenericTransformStream}} mixin will give an IDL interface the ap the behavior of the resulting interface, its constructor (or other initialization code) must set each instance's [=GenericTransformStream/transform=] to a [=new=] {{TransformStream}}, and then [=TransformStream/set up|set it up=] with appropriate customizations via the -[=TransformStream/set up/transformAlgorithm=] and optionally -[=TransformStream/set up/flushAlgorithm=] arguments. +[=TransformStream/set up/transformAlgorithm=] and any optional arguments. Note: Existing examples of this pattern on the web platform include {{CompressionStream}} and {{TextDecoderStream}}. [[COMPRESSION]] [[ENCODING]]