@@ -973,7 +973,7 @@ default-reader-asynciterator-prototype-internal-slots">Asynchronous iteration</h
973
973
ignore> stream</var> and |iterator|, are:
974
974
975
975
1. Let |reader| be |iterator|'s [=ReadableStream async iterator/reader=] .
976
- 1. If |reader|.[=ReadableStreamDefaultReader /[[stream]]=] is undefined, return [=a promise rejected with=] a {{TypeError}} .
976
+ 1. If |reader|.[=ReadableStreamGenericReader /[[stream]]=] is undefined, return [=a promise rejected with=] a {{TypeError}} .
977
977
1. Let |promise| be [=a new promise=] .
978
978
1. Let |readRequest| be a new [=read request=] with the following [=struct/items=] :
979
979
: [=read request/chunk steps=] , given |chunk|
@@ -996,7 +996,7 @@ default-reader-asynciterator-prototype-internal-slots">Asynchronous iteration</h
996
996
ignore> stream</var> , |iterator|, and |arg|, are:
997
997
998
998
1. Let |reader| be |iterator|'s [=ReadableStream async iterator/reader=] .
999
- 1. If |reader|.[=ReadableStreamDefaultReader /[[stream]]=] is undefined, return [=a promise resolved with=] undefined.
999
+ 1. If |reader|.[=ReadableStreamGenericReader /[[stream]]=] is undefined, return [=a promise resolved with=] undefined.
1000
1000
1. Assert: |reader|.[=ReadableStreamDefaultReader/[[readRequests]]=] is [=list/is empty|empty=] , as the async iterator machinery
1001
1001
guarantees that any previous calls to `next()` have settled before this is called.
1002
1002
1. If |iterator|'s [=ReadableStream async iterator/prevent cancel=] is false:
@@ -1007,6 +1007,62 @@ default-reader-asynciterator-prototype-internal-slots">Asynchronous iteration</h
1007
1007
1. Return [=a promise resolved with=] undefined.
1008
1008
</div>
1009
1009
1010
+ <h3 id="generic-reader-mixin">The {{ReadableStreamGenericReader}} interface mixin</h3>
1011
+
1012
+ The {{ReadableStreamGenericReader}} interface mixin defines common internal slots, getters and
1013
+ methods that are shared between {{ReadableStreamDefaultReader}} and {{ReadableStreamBYOBReader}}
1014
+ objects.
1015
+
1016
+ <h4 id="generic-reader-mixin-definition">Interface definition</h4>
1017
+
1018
+ The Web IDL definition for the {{ReadableStreamGenericReader}} interface mixin is given as follows:
1019
+
1020
+ <xmp class="idl">
1021
+ interface mixin ReadableStreamGenericReader {
1022
+ readonly attribute Promise<void> closed;
1023
+
1024
+ Promise<void> cancel(optional any reason);
1025
+ };
1026
+ </xmp>
1027
+
1028
+ <h4 id="generic-reader-internal-slots">Internal slots</h4>
1029
+
1030
+ Instances of classes implementing the {{ReadableStreamGenericReader}} mixin are created with the
1031
+ internal slots described in the following table:
1032
+
1033
+ <table dfn-for="ReadableStreamGenericReader">
1034
+ <thead>
1035
+ <tr>
1036
+ <th> Internal Slot
1037
+ <th> Description (<em> non-normative</em> )
1038
+ <tbody>
1039
+ <tr>
1040
+ <td> <dfn>\[[closedPromise]]</dfn>
1041
+ <td class="non-normative"> A promise returned by the reader's
1042
+ {{ReadableStreamGenericReader/closed}} getter
1043
+ <tr>
1044
+ <td> <dfn>\[[stream]]</dfn>
1045
+ <td class="non-normative"> A {{ReadableStream}} instance that owns this reader
1046
+ </table>
1047
+
1048
+ <h4 id="generic-reader-prototype">Methods and properties</h4>
1049
+
1050
+ <div algorithm>
1051
+ The <dfn id="generic-reader-closed" attribute for="ReadableStreamGenericReader">closed</dfn>
1052
+ getter steps are:
1053
+
1054
+ 1. Return [=this=] .[=ReadableStreamGenericReader/[[closedPromise]]=] .
1055
+ </div>
1056
+
1057
+ <div algorithm>
1058
+ The <dfn id="generic-reader-cancel" method for="ReadableStreamGenericReader">cancel(|reason|)</dfn>
1059
+ method steps are:
1060
+
1061
+ 1. If [=this=] .[=ReadableStreamGenericReader/[[stream]]=] is undefined, return [=a promise rejected with=] a {{TypeError}}
1062
+ exception.
1063
+ 1. Return ! [$ReadableStreamReaderGenericCancel$] ([=this=] , |reason|).
1064
+ </div>
1065
+
1010
1066
<h3 id="default-reader-class">The {{ReadableStreamDefaultReader}} class</h3>
1011
1067
1012
1068
The {{ReadableStreamDefaultReader}} class represents a [=default reader=] designed to be vended by a
@@ -1021,12 +1077,10 @@ The Web IDL definition for the {{ReadableStreamDefaultReader}} class is given as
1021
1077
interface ReadableStreamDefaultReader {
1022
1078
constructor(ReadableStream stream);
1023
1079
1024
- readonly attribute Promise<void> closed;
1025
-
1026
- Promise<void> cancel(optional any reason);
1027
1080
Promise<ReadableStreamDefaultReadResult> read();
1028
1081
void releaseLock();
1029
1082
};
1083
+ ReadableStreamDefaultReader includes ReadableStreamGenericReader;
1030
1084
1031
1085
dictionary ReadableStreamDefaultReadResult {
1032
1086
any value;
@@ -1036,28 +1090,19 @@ dictionary ReadableStreamDefaultReadResult {
1036
1090
1037
1091
<h4 id="default-reader-internal-slots">Internal slots</h4>
1038
1092
1039
- Instances of {{ReadableStreamDefaultReader}} are created with the internal slots described in the
1040
- following table:
1093
+ Instances of {{ReadableStreamDefaultReader}} are created with the internal slots defined by
1094
+ {{ReadableStreamGenericReader}} , and those described in the following table:
1041
1095
1042
1096
<table dfn-for="ReadableStreamDefaultReader">
1043
1097
<thead>
1044
1098
<tr>
1045
1099
<th> Internal Slot
1046
1100
<th> Description (<em> non-normative</em> )
1047
1101
<tbody>
1048
- <tr>
1049
- <td> <dfn>\[[closedPromise]]</dfn>
1050
- <td class="non-normative"> A promise returned by the reader's
1051
- {{ReadableStreamDefaultReader/closed}} getter.
1052
- This fulfills the [=ReadableStreamGenericReader/[[closedPromise]]=] contract.
1053
1102
<tr>
1054
1103
<td> <dfn>\[[readRequests]]</dfn>
1055
1104
<td class="non-normative"> A [=list=] of [=read requests=] , used when a [=consumer=] requests
1056
1105
[=chunks=] sooner than they are available
1057
- <tr>
1058
- <td> <dfn>\[[stream]]</dfn>
1059
- <td class="non-normative"> A {{ReadableStream}} instance that owns this reader
1060
- This fulfills the [=ReadableStreamGenericReader/[[stream]]=] contract.
1061
1106
</table>
1062
1107
1063
1108
A <dfn export>read request</dfn> is a [=struct=] containing three algorithms to perform in reaction
@@ -1133,14 +1178,14 @@ to filling the [=readable stream=]'s [=internal queue=] or changing its state. I
1133
1178
The <dfn id="default-reader-closed" attribute for="ReadableStreamDefaultReader">closed</dfn>
1134
1179
getter steps are:
1135
1180
1136
- 1. Return [=this=] .[=ReadableStreamDefaultReader /[[closedPromise]]=] .
1181
+ 1. Return [=this=] .[=ReadableStreamGenericReader /[[closedPromise]]=] .
1137
1182
</div>
1138
1183
1139
1184
<div algorithm>
1140
1185
The <dfn id="default-reader-cancel" method for="ReadableStreamDefaultReader">cancel(|reason|)</dfn>
1141
1186
method steps are:
1142
1187
1143
- 1. If [=this=] .[=ReadableStreamDefaultReader /[[stream]]=] is undefined, return [=a promise rejected with=] a {{TypeError}}
1188
+ 1. If [=this=] .[=ReadableStreamGenericReader /[[stream]]=] is undefined, return [=a promise rejected with=] a {{TypeError}}
1144
1189
exception.
1145
1190
1. Return ! [$ReadableStreamReaderGenericCancel$] ([=this=] , |reason|).
1146
1191
</div>
@@ -1149,7 +1194,7 @@ to filling the [=readable stream=]'s [=internal queue=] or changing its state. I
1149
1194
The <dfn id="default-reader-read" method for="ReadableStreamDefaultReader">read()</dfn>
1150
1195
method steps are:
1151
1196
1152
- 1. If [=this=] .[=ReadableStreamDefaultReader /[[stream]]=] is undefined, return [=a promise rejected with=] a {{TypeError}}
1197
+ 1. If [=this=] .[=ReadableStreamGenericReader /[[stream]]=] is undefined, return [=a promise rejected with=] a {{TypeError}}
1153
1198
exception.
1154
1199
1. Let |promise| be [=a new promise=] .
1155
1200
1. Let |readRequest| be a new [=read request=] with the following [=struct/items=] :
@@ -1172,7 +1217,7 @@ to filling the [=readable stream=]'s [=internal queue=] or changing its state. I
1172
1217
The <dfn id="default-reader-release-lock" method
1173
1218
for="ReadableStreamDefaultReader"> releaseLock()</dfn> method steps are:
1174
1219
1175
- 1. If [=this=] .[=ReadableStreamDefaultReader /[[stream]]=] is undefined, return.
1220
+ 1. If [=this=] .[=ReadableStreamGenericReader /[[stream]]=] is undefined, return.
1176
1221
1. If [=this=] .[=ReadableStreamDefaultReader/[[readRequests]]=] is not [=list/is empty|empty=] , throw a {{TypeError}} exception.
1177
1222
1. Perform ! [$ReadableStreamReaderGenericRelease$] ([=this=] ).
1178
1223
</div>
@@ -1191,12 +1236,10 @@ The Web IDL definition for the {{ReadableStreamBYOBReader}} class is given as fo
1191
1236
interface ReadableStreamBYOBReader {
1192
1237
constructor(ReadableStream stream);
1193
1238
1194
- readonly attribute Promise<void> closed;
1195
-
1196
- Promise<void> cancel(optional any reason);
1197
1239
Promise<ReadableStreamBYOBReadResult> read(ArrayBufferView view);
1198
1240
void releaseLock();
1199
1241
};
1242
+ ReadableStreamBYOBReader includes ReadableStreamGenericReader;
1200
1243
1201
1244
dictionary ReadableStreamBYOBReadResult {
1202
1245
ArrayBufferView value;
@@ -1206,28 +1249,19 @@ dictionary ReadableStreamBYOBReadResult {
1206
1249
1207
1250
<h4 id="byob-reader-internal-slots">Internal slots</h4>
1208
1251
1209
- Instances of {{ReadableStreamBYOBReader}} are created with the internal slots described in the
1210
- following table:
1252
+ Instances of {{ReadableStreamBYOBReader}} are created with the internal slots defined by
1253
+ {{ReadableStreamGenericReader}} , and those described in the following table:
1211
1254
1212
1255
<table dfn-for="ReadableStreamBYOBReader">
1213
1256
<thead>
1214
1257
<tr>
1215
1258
<th> Internal Slot
1216
1259
<th> Description (<em> non-normative</em> )
1217
1260
<tbody>
1218
- <tr>
1219
- <td> <dfn>\[[closedPromise]]</dfn>
1220
- <td class="non-normative"> A promise returned by the reader's
1221
- {{ReadableStreamBYOBReader/closed}} getter.
1222
- This fulfills the [=ReadableStreamGenericReader/[[closedPromise]]=] contract.
1223
1261
<tr>
1224
1262
<td> <dfn>\[[readIntoRequests]]</dfn>
1225
1263
<td class="non-normative"> A [=list=] of [=read-into requests=] , used when a [=consumer=] requests
1226
1264
[=chunks=] sooner than they are available
1227
- <tr>
1228
- <td> <dfn>\[[stream]]</dfn>
1229
- <td class="non-normative"> A {{ReadableStream}} instance that owns this reader.
1230
- This fulfills the [=ReadableStreamGenericReader/[[stream]]=] contract.
1231
1265
</table>
1232
1266
1233
1267
A <dfn export>read-into request</dfn> is a [=struct=] containing three algorithms to perform in
@@ -1314,14 +1348,14 @@ value: newViewOnSameMemory, done: true }</code> for closed streams, instead of t
1314
1348
The <dfn id="byob-reader-closed" attribute for="ReadableStreamBYOBReader">closed</dfn>
1315
1349
getter steps are:
1316
1350
1317
- 1. Return [=this=] .[=ReadableStreamBYOBReader /[[closedPromise]]=] .
1351
+ 1. Return [=this=] .[=ReadableStreamGenericReader /[[closedPromise]]=] .
1318
1352
</div>
1319
1353
1320
1354
<div algorithm>
1321
1355
The <dfn id="byob-reader-cancel" method for="ReadableStreamBYOBReader">cancel(|reason|)</dfn>
1322
1356
method steps are:
1323
1357
1324
- 1. If [=this=] .[=ReadableStreamBYOBReader /[[stream]]=] is undefined, return [=a promise rejected with=] a {{TypeError}}
1358
+ 1. If [=this=] .[=ReadableStreamGenericReader /[[stream]]=] is undefined, return [=a promise rejected with=] a {{TypeError}}
1325
1359
exception.
1326
1360
1. Return ! [$ReadableStreamReaderGenericCancel$] ([=this=] , |reason|).
1327
1361
</div>
@@ -1333,7 +1367,7 @@ value: newViewOnSameMemory, done: true }</code> for closed streams, instead of t
1333
1367
1. If |view|.\[[ByteLength]] is 0, return [=a promise rejected with=] a {{TypeError}} exception.
1334
1368
1. If |view|.\[[ViewedArrayBuffer]] .\[[ArrayBufferByteLength]] is 0, return [=a promise rejected
1335
1369
with=] a {{TypeError}} exception.
1336
- 1. If [=this=] .[=ReadableStreamBYOBReader /[[stream]]=] is undefined, return [=a promise rejected with=] a {{TypeError}}
1370
+ 1. If [=this=] .[=ReadableStreamGenericReader /[[stream]]=] is undefined, return [=a promise rejected with=] a {{TypeError}}
1337
1371
exception.
1338
1372
1. Let |promise| be [=a new promise=] .
1339
1373
1. Let |readIntoRequest| be a new [=read-into request=] with the following [=struct/items=] :
@@ -1356,7 +1390,7 @@ value: newViewOnSameMemory, done: true }</code> for closed streams, instead of t
1356
1390
The <dfn id="byob-reader-release-lock" method
1357
1391
for="ReadableStreamBYOBReader"> releaseLock()</dfn> method steps are:
1358
1392
1359
- 1. If [=this=] .[=ReadableStreamBYOBReader /[[stream]]=] is undefined, return.
1393
+ 1. If [=this=] .[=ReadableStreamGenericReader /[[stream]]=] is undefined, return.
1360
1394
1. If [=this=] .[=ReadableStreamBYOBReader/[[readIntoRequests]]=] is not [=list/is empty|empty=] , throw a {{TypeError}}
1361
1395
exception.
1362
1396
1. Perform ! [$ReadableStreamReaderGenericRelease$] ([=this=] ).
@@ -1523,7 +1557,7 @@ counterparts for BYOB controllers, as discussed in [[#rs-abstract-ops-used-by-co
1523
1557
id="rs-default-controller-private-pull"> \[[PullSteps]] (|readRequest|)</dfn> implements the
1524
1558
[$ReadableStreamController/[[PullSteps] ]$] contract. It performs the following steps:
1525
1559
1526
- 1. Let |stream| be [=this=] .[=ReadableStreamBYOBReader /[[stream]]=] .
1560
+ 1. Let |stream| be [=this=] .[=ReadableStreamGenericReader /[[stream]]=] .
1527
1561
1. If [=this=] .\[[queue]] is not [=list/is empty|empty=] ,
1528
1562
1. Let |chunk| be ! [$DequeueValue$] ([=this=] ).
1529
1563
1. If [=this=] .\[[closeRequested]] is true and [=this=] .\[[queue]] [=list/is empty=] ,
@@ -1736,7 +1770,7 @@ has the following [=struct/items=]:
1736
1770
steps are:
1737
1771
1738
1772
1. If [=this=] .\[[closeRequested]] is true, throw a {{TypeError}} exception.
1739
- 1. If [=this=] .[=ReadableStreamBYOBReader /[[stream]]=] .[=ReadableStream/[[state]]=] is not "`readable`", throw a {{TypeError}} exception.
1773
+ 1. If [=this=] .[=ReadableStreamGenericReader /[[stream]]=] .[=ReadableStream/[[state]]=] is not "`readable`", throw a {{TypeError}} exception.
1740
1774
1. Perform ? [$ReadableByteStreamControllerClose$] ([=this=] ).
1741
1775
</div>
1742
1776
@@ -1748,7 +1782,7 @@ for="ReadableByteStreamController">enqueue(|chunk|)</dfn> method steps are:
1748
1782
1. If |chunk|.\[[ViewedArrayBuffer]] .\[[ArrayBufferByteLength]] is 0, throw a {{TypeError}}
1749
1783
exception.
1750
1784
1. If [=this=] .\[[closeRequested]] is true, throw a {{TypeError}} exception.
1751
- 1. If [=this=] .[=ReadableStreamBYOBReader /[[stream]]=] .[=ReadableStream/[[state]]=] is not "`readable`", throw a {{TypeError}} exception.
1785
+ 1. If [=this=] .[=ReadableStreamGenericReader /[[stream]]=] .[=ReadableStream/[[state]]=] is not "`readable`", throw a {{TypeError}} exception.
1752
1786
1. Return ! [$ReadableByteStreamControllerEnqueue$] ([=this=] , |chunk|).
1753
1787
</div>
1754
1788
@@ -2189,7 +2223,7 @@ create them does not matter.
2189
2223
[$ReadableStreamDefaultControllerEnqueue$] (|branch2|.[=ReadableStream/[[controller]]=] , |value2|).
2190
2224
2191
2225
<p class="note"> The microtask delay here is necessary because it takes at least a microtask to
2192
- detect errors, when we use |reader|.[=ReadableStreamDefaultReader /[[closedPromise]]=] below. We want errors in |stream| to
2226
+ detect errors, when we use |reader|.[=ReadableStreamGenericReader /[[closedPromise]]=] below. We want errors in |stream| to
2193
2227
error both branches immediately, so we cannot let successful synchronously-available reads
2194
2228
happen ahead of asynchronously-available errors.
2195
2229
@@ -2228,7 +2262,7 @@ create them does not matter.
2228
2262
|cancel1Algorithm|).
2229
2263
1. Set |branch2| to ! [$CreateReadableStream$] (|startAlgorithm|, |pullAlgorithm|,
2230
2264
|cancel2Algorithm|).
2231
- 1. [=Upon rejection=] of |reader|.[=ReadableStreamDefaultReader /[[closedPromise]]=] with reason |r|,
2265
+ 1. [=Upon rejection=] of |reader|.[=ReadableStreamGenericReader /[[closedPromise]]=] with reason |r|,
2232
2266
1. Perform ! [$ReadableStreamDefaultControllerError$] (|branch1|.[=ReadableStream/[[controller]]=] , |r|).
2233
2267
1. Perform ! [$ReadableStreamDefaultControllerError$] (|branch2|.[=ReadableStream/[[controller]]=] , |r|).
2234
2268
1. [=Resolve=] |cancelPromise| with undefined.
@@ -2413,23 +2447,6 @@ the {{ReadableStream}}'s public API.
2413
2447
2414
2448
<h4 id="rs-reader-abstract-ops">Readers</h4>
2415
2449
2416
- Instances of {{ReadableStreamDefaultReader}} and {{ReadableStreamBYOBReader}} are created with the
2417
- internal slots described in the following table:
2418
-
2419
- <table dfn-for="ReadableStreamGenericReader">
2420
- <thead>
2421
- <tr>
2422
- <th> Internal Slot
2423
- <th> Description (<em> non-normative</em> )
2424
- <tbody>
2425
- <tr>
2426
- <td> <dfn>\[[closedPromise]]</dfn>
2427
- <td class="non-normative"> A promise returned by the reader's <code> closed</code> getter
2428
- <tr>
2429
- <td> <dfn>\[[stream]]</dfn>
2430
- <td class="non-normative"> A {{ReadableStream}} instance that owns this reader
2431
- </table>
2432
-
2433
2450
The following abstract operations support the implementation and manipulation of
2434
2451
{{ReadableStreamDefaultReader}} and {{ReadableStreamBYOBReader}} instances.
2435
2452
@@ -2481,7 +2498,7 @@ The following abstract operations support the implementation and manipulation of
2481
2498
id="readable-stream-byob-reader-read"> ReadableStreamBYOBReaderRead(|reader|, |view|,
2482
2499
|readIntoRequest|)</dfn> performs the following steps:
2483
2500
2484
- 1. Let |stream| be |reader|.[=ReadableStreamBYOBReader /[[stream]]=] .
2501
+ 1. Let |stream| be |reader|.[=ReadableStreamGenericReader /[[stream]]=] .
2485
2502
1. Assert: |stream| is not undefined.
2486
2503
1. Set |stream|.[=ReadableStream/[[disturbed]]=] to true.
2487
2504
1. If |stream|.[=ReadableStream/[[state]]=] is "`errored`", perform |readIntoRequest|'s [=read-into request/error
@@ -2495,7 +2512,7 @@ The following abstract operations support the implementation and manipulation of
2495
2512
id="readable-stream-default-reader-read"> ReadableStreamDefaultReaderRead(|reader|,
2496
2513
|readRequest|)</dfn> performs the following steps:
2497
2514
2498
- 1. Let |stream| be |reader|.[=ReadableStreamDefaultReader /[[stream]]=] .
2515
+ 1. Let |stream| be |reader|.[=ReadableStreamGenericReader /[[stream]]=] .
2499
2516
1. Assert: |stream| is not undefined.
2500
2517
1. Set |stream|.[=ReadableStream/[[disturbed]]=] to true.
2501
2518
1. If |stream|.[=ReadableStream/[[state]]=] is "`closed`", perform |readRequest|'s [=read request/close steps=] .
0 commit comments