@@ -4302,19 +4302,17 @@ and {{@@asyncIterator}} properties on its [=interface prototype object=].
4302
4302
4303
4303
Prose accompanying an [=interface=] with an [=asynchronously iterable declaration=] must define a
4304
4304
<dfn id="dfn-get-the-next-iteration-result">get the next iteration result</dfn> algorithm.
4305
- This algorithm receives a <b>[=this=]</b> value, which is an instance of the [=interface=] that it
4306
- is defined for, and the <dfn export>current state</dfn> .
4305
+ This algorithm receives the instance of the [=interface=] that is being iterated, as well as the
4306
+ async iterator itself (which can be useful for storing state) .
4307
4307
It must return a {{Promise}} that either resolves with undefined – to signal the end of the
4308
- iteration – or a tuple with three elements:
4308
+ iteration – or a tuple with two elements:
4309
4309
4310
4310
1. a value of the first type given in the declaration;
4311
- 1. a value of the second type given in the declaration;
4312
- 1. an opaque value that is passed back to the next invocation of the algorithm as the
4313
- <b>[=current state=]</b>.
4311
+ 1. a value of the second type given in the declaration.
4314
4312
4315
4313
The prose may also define <dfn>asynchronous iterator initialization steps</dfn> for the
4316
4314
[=interface=] with an [=asynchronously iterable declaration=], which would then be called with the
4317
- newly created iterator object.
4315
+ instance of the [=interface=] being iterated, as well as the newly created iterator object.
4318
4316
4319
4317
[=Interfaces=] with an [=asynchronously iterable declaration=] must not have any
4320
4318
[=interface members=] named "<code>entries</code>", "<code>keys</code>", or "<code>values</code>",
@@ -4344,26 +4342,35 @@ or have any [=inherited interfaces=] that have [=interface members=] with these
4344
4342
4345
4343
<blockquote>
4346
4344
4347
- To [=get the next iteration result=] for <code class="idl">SessionManager</code>, run the
4348
- following steps:
4345
+ The [=asynchronous iterator initialization steps=] for a <code class="idl">SessionManager</code>
4346
+ async iterator |iterator| are:
4347
+
4348
+ 1. Set |iterator|'s <dfn for="SessionManager async iterator">current state</dfn> to "not
4349
+ yet started".
4350
+
4351
+ To [=get the next iteration result=] for a <code class="idl">SessionManager</code>
4352
+ |manager| and its async iterator |iterator|:
4349
4353
4350
4354
1. Let |promise| be a new promise.
4351
4355
1. Let |key| be the following value, if it exists, or null otherwise:
4352
4356
<dl class="switch">
4353
- : If <b>current state</b> is "not yet started"
4354
- :: the smallest username in <b>this</b>'s open sessions, in lexicographical order
4357
+ : If |iterator|'s [=SessionManager async iterator/current state=] is "not yet
4358
+ started"
4359
+ :: the smallest username in |manager|'s open sessions, in lexicographical order
4355
4360
4356
4361
: Otherwise
4357
- :: the smallest username in <b>this</b> 's open sessions that is greater than
4358
- <b> current state</b> , in lexicographical order
4362
+ :: the smallest username in |manager| 's open sessions that is greater than
4363
+ |iterator|'s current state, in lexicographical order
4359
4364
</dl>
4360
4365
4361
- Note: <b>current state</b> might no longer be present in the open sessions.
4366
+ Note: |iterator|'s [=SessionManager async iterator/current state=] might no longer be
4367
+ present in the open sessions.
4362
4368
1. If |key| is null, then:
4363
4369
1. Resolve |promise| with undefined.
4364
4370
1. Otherwise:
4365
4371
1. Let |session| be the <code class="idl">Session</code> object corresponding to |key|.
4366
- 1. Resolve |promise| with (|username|, |session|, |username|).
4372
+ 1. Resolve |promise| with (|username|, |session|).
4373
+ 1. Set |iterator|'s [=SessionManager async iterator/current state=] to |username|.
4367
4374
1. Return |promise|.
4368
4375
4369
4376
</blockquote>
@@ -12115,10 +12122,11 @@ The location of the property is determined as follows:
12115
12122
1. If |object| does not [=implement=] |interface|, then [=ECMAScript/throw=] a
12116
12123
{{ECMAScript/TypeError}}.
12117
12124
1. Let |iterator| be a newly created [=default asynchronous iterator object=] for |interface|
12118
- with |object| as its [=default asynchronous iterator object/target=] and
12119
- "<code>key+value</code>" as its [=default asynchronous iterator object/kind=].
12120
- 1. Run the [=asynchronous iterator initialization steps=] for |interface| with |iterator|, if
12121
- any.
12125
+ with |object| as its [=default asynchronous iterator object/target=],
12126
+ "<code>key+value</code>" as its [=default asynchronous iterator object/kind=], and
12127
+ [=default asynchronous iterator object/is finished=] set to false.
12128
+ 1. Run the [=asynchronous iterator initialization steps=] for |interface| with |object| and
12129
+ |iterator|, if any such steps exist.
12122
12130
1. Return |iterator|.
12123
12131
</div>
12124
12132
@@ -12305,10 +12313,11 @@ then the [=function object=] is {{%ArrayProto_keys%}}.
12305
12313
1. If |object| does not [=implement=] |interface|, then [=ECMAScript/throw=] a
12306
12314
{{ECMAScript/TypeError}}.
12307
12315
1. Let |iterator| be a newly created [=default asynchronous iterator object=] for |interface|
12308
- with |object| as its [=default asynchronous iterator object/target=] and
12309
- "<code>key</code>" as its [=default asynchronous iterator object/kind=].
12310
- 1. Run the [=asynchronous iterator initialization steps=] for |interface| with |iterator|, if
12311
- any.
12316
+ with |object| as its [=default asynchronous iterator object/target=],
12317
+ "<code>key</code>" as its [=default asynchronous iterator object/kind=], and
12318
+ [=default asynchronous iterator object/is finished=] set to false.
12319
+ 1. Run the [=asynchronous iterator initialization steps=] for |interface| with |object| and
12320
+ |iterator|, if any such steps exist.
12312
12321
1. Return |iterator|.
12313
12322
</div>
12314
12323
@@ -12369,10 +12378,11 @@ the value of the {{@@iterator}} property.
12369
12378
1. If |object| does not [=implement=] |interface|, then [=ECMAScript/throw=] a
12370
12379
{{ECMAScript/TypeError}}.
12371
12380
1. Let |iterator| be a newly created [=default asynchronous iterator object=] for |interface|
12372
- with |object| as its [=default asynchronous iterator object/target=] and
12373
- "<code>value</code>" as its [=default asynchronous iterator object/kind=].
12374
- 1. Run the [=asynchronous iterator initialization steps=] for |interface| with |iterator|, if
12375
- any.
12381
+ with |object| as its [=default asynchronous iterator object/target=],
12382
+ "<code>value</code>" as its [=default asynchronous iterator object/kind=], and
12383
+ [=default asynchronous iterator object/is finished=] set to false.
12384
+ 1. Run the [=asynchronous iterator initialization steps=] for |interface| with |object| and
12385
+ |iterator|, if any such steps exist.
12376
12386
1. Return |iterator|.
12377
12387
</div>
12378
12388
@@ -12495,16 +12505,7 @@ A [=default asynchronous iterator object=] has internal values:
12495
12505
* its <dfn for="default asynchronous iterator object">kind</dfn>, which is the iteration kind,
12496
12506
* its <dfn for="default asynchronous iterator object">ongoing promise</dfn>, which is a
12497
12507
{{Promise}} or undefined,
12498
- * its <dfn for="default asynchronous iterator object">state</dfn>, which is one of
12499
- "not yet started" and "finished", or an opaque value used to store the position of the iterator
12500
- by the algorithm to [=get the next iteration result=].
12501
-
12502
- Note: This value is associated with the iterator instance, rather than the [=interface=]
12503
- instance. It is explicitly handled here because the iterator instance is not exposed to the
12504
- prose that [=get the next iteration result|gets the next iteration result=].
12505
-
12506
- When a [=default asynchronous iterator object=] is first created, its
12507
- [=default asynchronous iterator object/state=] is "not yet started".
12508
+ * its <dfn for="default asynchronous iterator object">is finished</dfn>, which is a boolean.
12508
12509
12509
12510
Note: [=Default asynchronous iterator objects=] do not have [=class strings=]; when
12510
12511
<code class="idl">Object.prototype.toString()</code> is called on a
@@ -12559,8 +12560,7 @@ The \[[Prototype]] [=internal slot=] of an [=asynchronous iterator prototype obj
12559
12560
12560
12561
1. Let |nextSteps| be the following steps:
12561
12562
1. Let |nextPromiseCapability| be [=!=] [$NewPromiseCapability$]({{%Promise%}}).
12562
- 1. Let |oldState| be |object|'s [=default asynchronous iterator object/state=].
12563
- 1. If |oldState| is "finished", then:
12563
+ 1. If |object|'s [=default asynchronous iterator object/is finished=] is true, then:
12564
12564
1. Let |result| be [$CreateIterResultObject$](<emu-val>undefined</emu-val>,
12565
12565
<emu-val>true</emu-val>).
12566
12566
1. Perform [=!=] [$Call$](|nextPromiseCapability|.\[[Resolve]],
@@ -12569,20 +12569,18 @@ The \[[Prototype]] [=internal slot=] of an [=asynchronous iterator prototype obj
12569
12569
1. Let |kind| be |object|'s [=default asynchronous iterator object/kind=].
12570
12570
1. Let |nextPromise| be the result of
12571
12571
[=get the next iteration result|getting the next iteration result=] with |object|'s
12572
- [=default asynchronous iterator object/target=] as <b>[=this=]</b> and |oldState| as
12573
- the <b>[=current state=]</b>.
12572
+ [=default asynchronous iterator object/target=] and |object|.
12574
12573
1. Let |resolveSteps| be the following steps, given |next|:
12575
12574
1. Set |object|'s [=default asynchronous iterator object/ongoing promise=] to
12576
12575
undefined.
12577
12576
1. If |next| is undefined, then:
12578
- 1. Set |object|'s [=default asynchronous iterator object/state =] to null .
12577
+ 1. Set |object|'s [=default asynchronous iterator object/is finished =] to true .
12579
12578
1. Let |result| be [$CreateIterResultObject$](<emu-val>undefined</emu-val>,
12580
12579
<emu-val>true</emu-val>).
12581
12580
1. Perform [=!=] [$Call$](|nextPromiseCapability|.\[[Resolve]],
12582
12581
<emu-val>undefined</emu-val>, « |result| »).
12583
12582
1. Otherwise:
12584
- 1. Let (|key|, |value|, |newState|) be |next|.
12585
- 1. Set |object|'s [=default asynchronous iterator object/state=] to |newState|.
12583
+ 1. Let (|key|, |value|) be |next|.
12586
12584
1. Let |result| be the [=iterator result=] for (|key|, |value|) and |kind|.
12587
12585
1. Perform [=!=] [$Call$](|nextPromiseCapability|.\[[Resolve]],
12588
12586
<emu-val>undefined</emu-val>, « |result| »).
0 commit comments