Skip to content

Commit 9d11c76

Browse files
committed
Editorial: async iterator cleanups
* Export the terms we expect people to use * Highlight the samples as Web IDL * Clean up the description of the initialization steps * Simplify the algorithm for next a bit
1 parent 4e0aff4 commit 9d11c76

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

index.bs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4287,7 +4287,7 @@ An [=interface=] can be declared to be asynchronously iterable by using an
42874287
(matching <emu-nt><a href="#prod-AsyncIterable">AsyncIterable</a></emu-nt>) in the body of the
42884288
[=interface=].
42894289

4290-
<pre class="syntax">
4290+
<pre highlight="webidl" class="syntax">
42914291
interface interface_identifier {
42924292
async iterable&lt;key_type, value_type&gt;;
42934293
};
@@ -4301,7 +4301,7 @@ Note: In the ECMAScript language binding, an interface that is asynchronously it
43014301
and {{@@asyncIterator}} properties on its [=interface prototype object=].
43024302

43034303
Prose accompanying an [=interface=] with an [=asynchronously iterable declaration=] must define a
4304-
<dfn id="dfn-get-the-next-iteration-result">get the next iteration result</dfn> algorithm.
4304+
<dfn id="dfn-get-the-next-iteration-result" export>get the next iteration result</dfn> algorithm.
43054305
This algorithm receives the instance of the [=interface=] that is being iterated, as well as the
43064306
async iterator itself (which can be useful for storing state).
43074307
It must return a {{Promise}} that either rejects, resolves with undefined to signal the end of the
@@ -4310,9 +4310,9 @@ iteration, or resolves with a tuple containing two elements:
43104310
1. a value of the first type given in the declaration;
43114311
1. a value of the second type given in the declaration.
43124312

4313-
The prose may also define <dfn>asynchronous iterator initialization steps</dfn> for the
4314-
[=interface=] with an [=asynchronously iterable declaration=], which would then be called with the
4315-
instance of the [=interface=] being iterated, as well as the newly created iterator object.
4313+
The prose may also define <dfn export>asynchronous iterator initialization steps</dfn>. These
4314+
receive the instance of the [=interface=] being iterated, as well as the newly-created
4315+
iterator object.
43164316

43174317
[=Interfaces=] with an [=asynchronously iterable declaration=] must not have any
43184318
[=interface members=] named "<code>entries</code>", "<code>keys</code>", or "<code>values</code>",
@@ -4323,7 +4323,7 @@ or have any [=inherited interfaces=] that have [=interface members=] with these
43234323
Consider the following interface <code class="idl">SessionManager</code>, which allows access
43244324
to a number of <code class="idl">Session</code> objects keyed by username:
43254325

4326-
<pre>
4326+
<pre highlight="webidl">
43274327
[Exposed=Window]
43284328
interface SessionManager {
43294329
Session getSessionForUser(DOMString username);
@@ -12552,7 +12552,6 @@ The \[[Prototype]] [=internal slot=] of an [=asynchronous iterator prototype obj
1255212552
1. Return |thisValidationPromiseCapability|.\[[Promise]].
1255312553

1255412554
1. If |object| is not a [=default asynchronous iterator object=] for |interface|, then:
12555-
1. Issue: [=Realm=] check?
1255612555
1. Let |error| be a new {{ECMAScript/TypeError}}.
1255712556
1. Perform [=!=] [$Call$](|thisValidationPromiseCapability|.\[[Reject]],
1255812557
<emu-val>undefined</emu-val>, « |error| »).
@@ -12570,21 +12569,16 @@ The \[[Prototype]] [=internal slot=] of an [=asynchronous iterator prototype obj
1257012569
1. Let |nextPromise| be the result of
1257112570
[=get the next iteration result|getting the next iteration result=] with |object|'s
1257212571
[=default asynchronous iterator object/target=] and |object|.
12573-
1. Let |resolveSteps| be the following steps, given |next|:
12572+
1. Let |fulfillSteps| be the following steps, given |next|:
1257412573
1. Set |object|'s [=default asynchronous iterator object/ongoing promise=] to
1257512574
undefined.
1257612575
1. If |next| is undefined, then:
1257712576
1. Set |object|'s [=default asynchronous iterator object/is finished=] to true.
12578-
1. Let |result| be [$CreateIterResultObject$](<emu-val>undefined</emu-val>,
12577+
1. Return [=!=] [$CreateIterResultObject$](<emu-val>undefined</emu-val>,
1257912578
<emu-val>true</emu-val>).
12580-
1. Perform [=!=] [$Call$](|nextPromiseCapability|.\[[Resolve]],
12581-
<emu-val>undefined</emu-val>, « |result| »).
1258212579
1. Otherwise:
12583-
1. Let (|key|, |value|) be |next|.
12584-
1. Let |result| be the [=iterator result=] for (|key|, |value|) and |kind|.
12585-
1. Perform [=!=] [$Call$](|nextPromiseCapability|.\[[Resolve]],
12586-
<emu-val>undefined</emu-val>, « |result| »).
12587-
1. Let |onFulfilled| be [=!=] [$CreateBuiltinFunction$](|resolveSteps|, « »).
12580+
1. Return the [=iterator result=] for |next| and |kind|.
12581+
1. Let |onFulfilled| be [=!=] [$CreateBuiltinFunction$](|fulfillSteps|, « »).
1258812582
1. Perform [=!=] [$PerformPromiseThen$](|nextPromise|, |onFulfilled|,
1258912583
<emu-val>undefined</emu-val>, |nextPromiseCapability|).
1259012584
1. Return |nextPromiseCapability|.\[[Promise]].

0 commit comments

Comments
 (0)