@@ -1470,7 +1470,7 @@ interface ReadableStreamDefaultController {
14701470 readonly attribute unrestricted double? desiredSize;
14711471
14721472 undefined close();
1473- undefined enqueue(optional any chunk);
1473+ undefined enqueue(optional any chunk, optional sequence <object> transfer = [] );
14741474 undefined error(optional any e);
14751475};
14761476</xmp>
@@ -1581,11 +1581,11 @@ the following table:
15811581
15821582<div algorithm>
15831583 The <dfn id="rs-default-controller-enqueue" method
1584- for="ReadableStreamDefaultController"> enqueue(|chunk|)</dfn> method steps are:
1584+ for="ReadableStreamDefaultController"> enqueue(|chunk|, |transferList| )</dfn> method steps are:
15851585
15861586 1. If ! [$ReadableStreamDefaultControllerCanCloseOrEnqueue$] ([=this=] ) is false, throw a
15871587 {{TypeError}} exception.
1588- 1. Perform ? [$ReadableStreamDefaultControllerEnqueue$] ([=this=] , |chunk|).
1588+ 1. Perform ? [$ReadableStreamDefaultControllerEnqueue$] ([=this=] , |chunk|, |transferList| ).
15891589</div>
15901590
15911591<div algorithm>
@@ -2301,10 +2301,10 @@ create them does not matter.
23012301 1. Otherwise, set |chunk2| to |cloneResult|.\[[Value]] .
23022302 1. If |canceled1| is false, perform !
23032303 [$ReadableStreamDefaultControllerEnqueue$] (|branch1|.[=ReadableStream/[[controller]]=] ,
2304- |chunk1|).
2304+ |chunk1|, undefined ).
23052305 1. If |canceled2| is false, perform !
23062306 [$ReadableStreamDefaultControllerEnqueue$] (|branch2|.[=ReadableStream/[[controller]]=] ,
2307- |chunk2|).
2307+ |chunk2|, undefined ).
23082308 1. Set |reading| to false.
23092309 1. If |readAgain| is true, perform |pullAlgorithm|.
23102310
@@ -2964,16 +2964,18 @@ The following abstract operations support the implementation of the
29642964<div algorithm>
29652965 <dfn abstract-op lt="ReadableStreamDefaultControllerEnqueue"
29662966 id="readable-stream-default-controller-enqueue"> ReadableStreamDefaultControllerEnqueue(|controller|,
2967- |chunk|)</dfn> performs the following steps:
2967+ |chunk|, |transferList| )</dfn> performs the following steps:
29682968
29692969 1. If ! [$ReadableStreamDefaultControllerCanCloseOrEnqueue$] (|controller|) is false, return.
29702970 1. Let |stream| be |controller|.[=ReadableStreamDefaultController/[[stream]]=] .
29712971 1. If ! [$IsReadableStreamLocked$] (|stream|) is true and !
29722972 [$ReadableStreamGetNumReadRequests$] (|stream|) > 0, perform the following steps:
29732973 1. Let |internalChunk| be |chunk|.
29742974 1. If |controller|.[=ReadableStreamDefaultController/[[isTransferring]]=] is true, perform the following steps:
2975- 1. Set |internalChunk| to [$StructuredTransferOrSerialize$] (|chunk|).
2976- 1. If |internalChunk| is an abrupt completion, return.
2975+ 1. Set |internalChunk| to [$StructuredTransferOrClone$] (|chunk|, |transferList|).
2976+ 1. If |internalChunk| is an abrupt completion,
2977+ 1. Perform ! [$ReadableStreamDefaultControllerError$] (|controller|, |internalChunk|.\[[Value]] ).
2978+ 1. Return |internalChunk|.
29772979 1. ![$ReadableStreamFulfillReadRequest$] (|stream|, |internalChunk|, false).
29782980 1. Otherwise,
29792981 1. Let |result| be the result of performing
@@ -2983,7 +2985,7 @@ The following abstract operations support the implementation of the
29832985 1. Perform ! [$ReadableStreamDefaultControllerError$] (|controller|, |result|.\[[Value]] ).
29842986 1. Return |result|.
29852987 1. Let |chunkSize| be |result|.\[[Value]] .
2986- 1. Let |enqueueResult| be [$EnqueueValueWithSize$] (|controller|, |chunk|, |chunkSize|).
2988+ 1. Let |enqueueResult| be [$EnqueueValueWithSize$] (|controller|, |chunk|, |chunkSize|, |transferList| ).
29872989 1. If |enqueueResult| is an abrupt completion,
29882990 1. Perform ! [$ReadableStreamDefaultControllerError$] (|controller|, |enqueueResult|.\[[Value]] ).
29892991 1. Return |enqueueResult|.
@@ -5207,7 +5209,7 @@ The following abstract operations support the implementation of the
52075209 id="writable-stream-default-controller-close"> WritableStreamDefaultControllerClose(|controller|)</dfn>
52085210 performs the following steps:
52095211
5210- 1. Perform ! [$EnqueueValueWithSize$] (|controller|, [=close sentinel=] , 0).
5212+ 1. Perform ! [$EnqueueValueWithSize$] (|controller|, [=close sentinel=] , 0, undefined ).
52115213 1. Perform ! [$WritableStreamDefaultControllerAdvanceQueueIfNeeded$] (|controller|).
52125214</div>
52135215
@@ -5311,7 +5313,7 @@ The following abstract operations support the implementation of the
53115313 id="writable-stream-default-controller-write"> WritableStreamDefaultControllerWrite(|controller|,
53125314 |chunk|, |chunkSize|)</dfn> performs the following steps:
53135315
5314- 1. Let |enqueueResult| be [$EnqueueValueWithSize$] (|controller|, |chunk|, |chunkSize|).
5316+ 1. Let |enqueueResult| be [$EnqueueValueWithSize$] (|controller|, |chunk|, |chunkSize|, undefined ).
53155317 1. If |enqueueResult| is an abrupt completion,
53165318 1. Perform ! [$WritableStreamDefaultControllerErrorIfNeeded$] (|controller|,
53175319 |enqueueResult|.\[[Value]] ).
@@ -5905,7 +5907,7 @@ The following abstract operations support the implementaiton of the
59055907 1. If ! [$ReadableStreamDefaultControllerCanCloseOrEnqueue$] (|readableController|) is false, throw
59065908 a {{TypeError}} exception.
59075909 1. Let |enqueueResult| be [$ReadableStreamDefaultControllerEnqueue$] (|readableController|,
5908- |chunk|).
5910+ |chunk|, undefined ).
59095911 1. If |enqueueResult| is an abrupt completion,
59105912 1. Perform ! [$TransformStreamErrorWritableAndUnblockWrite$] (|stream|,
59115913 |enqueueResult|.\[[Value]] ).
@@ -6383,15 +6385,15 @@ for="value-with-size">value</dfn> and <dfn for="value-with-size">size</dfn>.
63836385
63846386<div algorithm>
63856387 <dfn abstract-op lt="EnqueueValueWithSize"
6386- id="enqueue-value-with-size"> EnqueueValueWithSize(|container|, |value|, |size|)</dfn> performs the
6388+ id="enqueue-value-with-size"> EnqueueValueWithSize(|container|, |value|, |size|, |transferList| )</dfn> performs the
63876389 following steps:
63886390
63896391 1. Assert: |container| has \[[queue]] and \[[queueTotalSize]] internal slots.
63906392 1. If ! [$IsNonNegativeNumber$] (|size|) is false, throw a {{RangeError}} exception.
63916393 1. If |size| is +∞, throw a {{RangeError}} exception.
63926394 1. Let |enqueuedValue| be |value|.
63936395 1. If |container|.\[[isTransferring]] is true, perform the following steps:
6394- 1. Set |enqueuedValue| to [$StructuredTransferOrSerialize $] (|value|).
6396+ 1. Set |enqueuedValue| to [$StructuredTransferOrClone $] (|value|, |transferList |).
63956397 1. If |enqueuedValue| is an abrupt completion, return.
63966398 1. [=list/Append=] a new [=value-with-size=] with [=value-with-size/value=] |enqueuedValue| and
63976399 [=value-with-size/size=] |size| to |container|.\[[queue]] .
@@ -6476,7 +6478,7 @@ abstract operations are used to implement these "cross-realm transforms".
64766478 1. Let |value| be ! [$Get$] (|data|, "`value`").
64776479 1. Assert: [$Type$] (|type|) is String.
64786480 1. If |type| is "`chunk`",
6479- 1. Perform ! [$ReadableStreamDefaultControllerEnqueue$] (|controller|, |value|).
6481+ 1. Perform ! [$ReadableStreamDefaultControllerEnqueue$] (|controller|, |value|, undefined ).
64806482 1. Otherwise, if |type| is "`close`",
64816483 1. Perform ! [$ReadableStreamDefaultControllerClose$] (|controller|).
64826484 1. Disentangle |port|.
@@ -6626,15 +6628,13 @@ The following abstract operations are a grab-bag of utilities.
66266628</div>
66276629
66286630<div algorithm>
6629- <dfn abstract-op lt="StructuredTransferOrSerialize">StructuredTransferOrSerialize (|value|)</dfn>
6631+ <dfn abstract-op lt="StructuredTransferOrClone">StructuredTransferOrClone (|value|, |transferList |)</dfn>
66306632 performs the following steps:
6631- 1. If |value| is [=transferable objects|transferable=] , perform the following steps:
6632- // FIXME: We should probably handle other transferable types like ArrayBuffers.
6633- 1. Let |serialized| be ! [$StructuredSerializeWithTransfer$] (|value|, « |value| »).
6634- 1. Let |deserialized| be ! [$StructuredDeserializeWithTransfer$] (|serialized|,
6635- [=the current Realm=] ).
6636- 1. return |deserialized|.\[[Deserialized]] .
6637- 1. Return [$StructuredClone$] (|value|).
6633+ 1. If |value| has either an \[[ArrayBufferData]] internal slot or a \[[Detached]] internal slot, perform the following steps:
6634+ 1. If |transferList| is undefined or [=list/is empty|is an empty list=] , set |transferList| to « |value| ».
6635+ 1. Let |serialized| be ! [$StructuredSerializeWithTransfer$] (|value|, |transferList|).
6636+ 1. Let |deserialized| be ! [$StructuredDeserializeWithTransfer$] (|serialized|, [=the current Realm=] ).
6637+ 1. return |deserialized|.\[[Deserialized]] .
66386638</div>
66396639
66406640<h2 id="other-specs">Using streams in other specifications</h2>
@@ -6768,13 +6768,13 @@ mark=] is greater than zero.
67686768</div>
67696769
67706770<div algorithm>
6771- To <dfn export for="ReadableStream">enqueue</dfn> the JavaScript value |chunk| into a
6772- {{ReadableStream}} |stream|:
6771+ To <dfn export for="ReadableStream">enqueue</dfn> the JavaScript value |chunk|
6772+ with an optional |transferList| into a {{ReadableStream}} |stream|:
67736773
67746774 1. If |stream|.[=ReadableStream/[[controller]]=] [=implements=]
67756775 {{ReadableStreamDefaultController}} ,
67766776 1. Perform ! [$ReadableStreamDefaultControllerEnqueue$] (|stream|.[=ReadableStream/[[controller]]=] ,
6777- |chunk|).
6777+ |chunk|, |transferList| ).
67786778 1. Otherwise,
67796779 1. Assert: |stream|.[=ReadableStream/[[controller]]=] [=implements=]
67806780 {{ReadableByteStreamController}} .
0 commit comments