Skip to content

Commit 21fa354

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 b1c5aa0 commit 21fa354

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

index.bs

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

4287-
<pre class="syntax">
4287+
<pre highlight="webidl" class="syntax">
42884288
interface interface_identifier {
42894289
async iterable&lt;key_type, value_type&gt;;
42904290
};
@@ -4298,7 +4298,7 @@ Note: In the ECMAScript language binding, an interface that is asynchronously it
42984298
and {{@@asyncIterator}} properties on its [=interface prototype object=].
42994299

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

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

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

4323-
<pre>
4324+
<pre highlight="webidl">
43244325
[Exposed=Window]
43254326
interface SessionManager {
43264327
Session getSessionForUser(DOMString username);
@@ -12546,7 +12547,6 @@ The \[[Prototype]] [=internal slot=] of an [=asynchronous iterator prototype obj
1254612547
1. Return |thisValidationPromiseCapability|.\[[Promise]].
1254712548

1254812549
1. If |object| is not a [=default asynchronous iterator object=] for |interface|, then:
12549-
1. Issue: [=Realm=] check?
1255012550
1. Let |error| be a new {{ECMAScript/TypeError}}.
1255112551
1. Perform [=!=] [$Call$](|thisValidationPromiseCapability|.\[[Reject]],
1255212552
<emu-val>undefined</emu-val>, « |error| »).
@@ -12564,21 +12564,16 @@ The \[[Prototype]] [=internal slot=] of an [=asynchronous iterator prototype obj
1256412564
1. Let |nextPromise| be the result of
1256512565
[=get the next iteration result|getting the next iteration result=] with |object|'s
1256612566
[=default asynchronous iterator object/target=] and |object|.
12567-
1. Let |resolveSteps| be the following steps, given |next|:
12567+
1. Let |fulfillSteps| be the following steps, given |next|:
1256812568
1. Set |object|'s [=default asynchronous iterator object/ongoing promise=] to
1256912569
undefined.
1257012570
1. If |next| is undefined, then:
1257112571
1. Set |object|'s [=default asynchronous iterator object/is finished=] to true.
12572-
1. Let |result| be [$CreateIterResultObject$](<emu-val>undefined</emu-val>,
12572+
1. Return [=!=] [$CreateIterResultObject$](<emu-val>undefined</emu-val>,
1257312573
<emu-val>true</emu-val>).
12574-
1. Perform [=!=] [$Call$](|nextPromiseCapability|.\[[Resolve]],
12575-
<emu-val>undefined</emu-val>, « |result| »).
1257612574
1. Otherwise:
12577-
1. Let (|key|, |value|) be |next|.
12578-
1. Let |result| be the [=iterator result=] for (|key|, |value|) and |kind|.
12579-
1. Perform [=!=] [$Call$](|nextPromiseCapability|.\[[Resolve]],
12580-
<emu-val>undefined</emu-val>, « |result| »).
12581-
1. Let |onFulfilled| be [=!=] [$CreateBuiltinFunction$](|resolveSteps|, « »).
12575+
1. Return the [=iterator result=] for |next| and |kind|.
12576+
1. Let |onFulfilled| be [=!=] [$CreateBuiltinFunction$](|fulfillSteps|, « »).
1258212577
1. Perform [=!=] [$PerformPromiseThen$](|nextPromise|, |onFulfilled|,
1258312578
<emu-val>undefined</emu-val>, |nextPromiseCapability|).
1258412579
1. Return |nextPromiseCapability|.\[[Promise]].

0 commit comments

Comments
 (0)