@@ -1470,7 +1470,7 @@ interface ReadableStreamDefaultController {
1470
1470
readonly attribute unrestricted double? desiredSize;
1471
1471
1472
1472
undefined close();
1473
- undefined enqueue(optional any chunk);
1473
+ undefined enqueue(optional any chunk, optional sequence <object> transfer = [] );
1474
1474
undefined error(optional any e);
1475
1475
};
1476
1476
</xmp>
@@ -1581,11 +1581,11 @@ the following table:
1581
1581
1582
1582
<div algorithm>
1583
1583
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:
1585
1585
1586
1586
1. If ! [$ReadableStreamDefaultControllerCanCloseOrEnqueue$] ([=this=] ) is false, throw a
1587
1587
{{TypeError}} exception.
1588
- 1. Perform ? [$ReadableStreamDefaultControllerEnqueue$] ([=this=] , |chunk|).
1588
+ 1. Perform ? [$ReadableStreamDefaultControllerEnqueue$] ([=this=] , |chunk|, |transferList| ).
1589
1589
</div>
1590
1590
1591
1591
<div algorithm>
@@ -2301,10 +2301,10 @@ create them does not matter.
2301
2301
1. Otherwise, set |chunk2| to |cloneResult|.\[[Value]] .
2302
2302
1. If |canceled1| is false, perform !
2303
2303
[$ReadableStreamDefaultControllerEnqueue$] (|branch1|.[=ReadableStream/[[controller]]=] ,
2304
- |chunk1|).
2304
+ |chunk1|, undefined ).
2305
2305
1. If |canceled2| is false, perform !
2306
2306
[$ReadableStreamDefaultControllerEnqueue$] (|branch2|.[=ReadableStream/[[controller]]=] ,
2307
- |chunk2|).
2307
+ |chunk2|, undefined ).
2308
2308
1. Set |reading| to false.
2309
2309
1. If |readAgain| is true, perform |pullAlgorithm|.
2310
2310
@@ -2964,16 +2964,18 @@ The following abstract operations support the implementation of the
2964
2964
<div algorithm>
2965
2965
<dfn abstract-op lt="ReadableStreamDefaultControllerEnqueue"
2966
2966
id="readable-stream-default-controller-enqueue"> ReadableStreamDefaultControllerEnqueue(|controller|,
2967
- |chunk|)</dfn> performs the following steps:
2967
+ |chunk|, |transferList| )</dfn> performs the following steps:
2968
2968
2969
2969
1. If ! [$ReadableStreamDefaultControllerCanCloseOrEnqueue$] (|controller|) is false, return.
2970
2970
1. Let |stream| be |controller|.[=ReadableStreamDefaultController/[[stream]]=] .
2971
2971
1. If ! [$IsReadableStreamLocked$] (|stream|) is true and !
2972
2972
[$ReadableStreamGetNumReadRequests$] (|stream|) > 0, perform the following steps:
2973
2973
1. Let |internalChunk| be |chunk|.
2974
2974
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|.
2977
2979
1. ![$ReadableStreamFulfillReadRequest$] (|stream|, |internalChunk|, false).
2978
2980
1. Otherwise,
2979
2981
1. Let |result| be the result of performing
@@ -2983,7 +2985,7 @@ The following abstract operations support the implementation of the
2983
2985
1. Perform ! [$ReadableStreamDefaultControllerError$] (|controller|, |result|.\[[Value]] ).
2984
2986
1. Return |result|.
2985
2987
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| ).
2987
2989
1. If |enqueueResult| is an abrupt completion,
2988
2990
1. Perform ! [$ReadableStreamDefaultControllerError$] (|controller|, |enqueueResult|.\[[Value]] ).
2989
2991
1. Return |enqueueResult|.
@@ -5207,7 +5209,7 @@ The following abstract operations support the implementation of the
5207
5209
id="writable-stream-default-controller-close"> WritableStreamDefaultControllerClose(|controller|)</dfn>
5208
5210
performs the following steps:
5209
5211
5210
- 1. Perform ! [$EnqueueValueWithSize$] (|controller|, [=close sentinel=] , 0).
5212
+ 1. Perform ! [$EnqueueValueWithSize$] (|controller|, [=close sentinel=] , 0, undefined ).
5211
5213
1. Perform ! [$WritableStreamDefaultControllerAdvanceQueueIfNeeded$] (|controller|).
5212
5214
</div>
5213
5215
@@ -5311,7 +5313,7 @@ The following abstract operations support the implementation of the
5311
5313
id="writable-stream-default-controller-write"> WritableStreamDefaultControllerWrite(|controller|,
5312
5314
|chunk|, |chunkSize|)</dfn> performs the following steps:
5313
5315
5314
- 1. Let |enqueueResult| be [$EnqueueValueWithSize$] (|controller|, |chunk|, |chunkSize|).
5316
+ 1. Let |enqueueResult| be [$EnqueueValueWithSize$] (|controller|, |chunk|, |chunkSize|, undefined ).
5315
5317
1. If |enqueueResult| is an abrupt completion,
5316
5318
1. Perform ! [$WritableStreamDefaultControllerErrorIfNeeded$] (|controller|,
5317
5319
|enqueueResult|.\[[Value]] ).
@@ -5905,7 +5907,7 @@ The following abstract operations support the implementaiton of the
5905
5907
1. If ! [$ReadableStreamDefaultControllerCanCloseOrEnqueue$] (|readableController|) is false, throw
5906
5908
a {{TypeError}} exception.
5907
5909
1. Let |enqueueResult| be [$ReadableStreamDefaultControllerEnqueue$] (|readableController|,
5908
- |chunk|).
5910
+ |chunk|, undefined ).
5909
5911
1. If |enqueueResult| is an abrupt completion,
5910
5912
1. Perform ! [$TransformStreamErrorWritableAndUnblockWrite$] (|stream|,
5911
5913
|enqueueResult|.\[[Value]] ).
@@ -6383,15 +6385,15 @@ for="value-with-size">value</dfn> and <dfn for="value-with-size">size</dfn>.
6383
6385
6384
6386
<div algorithm>
6385
6387
<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
6387
6389
following steps:
6388
6390
6389
6391
1. Assert: |container| has \[[queue]] and \[[queueTotalSize]] internal slots.
6390
6392
1. If ! [$IsNonNegativeNumber$] (|size|) is false, throw a {{RangeError}} exception.
6391
6393
1. If |size| is +∞, throw a {{RangeError}} exception.
6392
6394
1. Let |enqueuedValue| be |value|.
6393
6395
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 |).
6395
6397
1. If |enqueuedValue| is an abrupt completion, return.
6396
6398
1. [=list/Append=] a new [=value-with-size=] with [=value-with-size/value=] |enqueuedValue| and
6397
6399
[=value-with-size/size=] |size| to |container|.\[[queue]] .
@@ -6476,7 +6478,7 @@ abstract operations are used to implement these "cross-realm transforms".
6476
6478
1. Let |value| be ! [$Get$] (|data|, "`value`").
6477
6479
1. Assert: [$Type$] (|type|) is String.
6478
6480
1. If |type| is "`chunk`",
6479
- 1. Perform ! [$ReadableStreamDefaultControllerEnqueue$] (|controller|, |value|).
6481
+ 1. Perform ! [$ReadableStreamDefaultControllerEnqueue$] (|controller|, |value|, undefined ).
6480
6482
1. Otherwise, if |type| is "`close`",
6481
6483
1. Perform ! [$ReadableStreamDefaultControllerClose$] (|controller|).
6482
6484
1. Disentangle |port|.
@@ -6626,15 +6628,13 @@ The following abstract operations are a grab-bag of utilities.
6626
6628
</div>
6627
6629
6628
6630
<div algorithm>
6629
- <dfn abstract-op lt="StructuredTransferOrSerialize">StructuredTransferOrSerialize (|value|)</dfn>
6631
+ <dfn abstract-op lt="StructuredTransferOrClone">StructuredTransferOrClone (|value|, |transferList |)</dfn>
6630
6632
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]] .
6638
6638
</div>
6639
6639
6640
6640
<h2 id="other-specs">Using streams in other specifications</h2>
@@ -6768,13 +6768,13 @@ mark=] is greater than zero.
6768
6768
</div>
6769
6769
6770
6770
<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|:
6773
6773
6774
6774
1. If |stream|.[=ReadableStream/[[controller]]=] [=implements=]
6775
6775
{{ReadableStreamDefaultController}} ,
6776
6776
1. Perform ! [$ReadableStreamDefaultControllerEnqueue$] (|stream|.[=ReadableStream/[[controller]]=] ,
6777
- |chunk|).
6777
+ |chunk|, |transferList| ).
6778
6778
1. Otherwise,
6779
6779
1. Assert: |stream|.[=ReadableStream/[[controller]]=] [=implements=]
6780
6780
{{ReadableByteStreamController}} .
0 commit comments