Re: [whatwg/webidl] Add `async iterable<T>` type to WebIDL (PR #1397)

@domfarolino commented on this pull request.



> +</div>
+
+<div id="async-iterable-to-js" algorithm="convert an async iterable to a JavaScript value">
+    An IDL <a lt="async iterable">async iterable&lt;<var ignore>T</var>&gt;</a> value |V| is
+    [=converted to a JavaScript value|converted=] to a JavaScript object as follows:
+
+    1.  Return |V|'s [=JS async iterable/object=].
+</div>
+
+<h5 id="js-async-iterator-iteration">Iterating async iterators</h5>
+
+An [=async iterable=] is not directly iterated over. Instead, it is first opened to create
+an [=async iterator=]. The [=async iterator=] can be asynchronously iterated over to produce values.
+
+<dfn lt="async iterator" export>Async iterators</dfn> are [=structs=] with the following [=struct/items=]:
+* <dfn for="JS async iterator">underlying record</dfn>, an [=Iterator=] record

ECMAScript routinely refers to these as the type "Iterator Record". The term is often linkable as "Iterator Record" too, so could we maybe follow suit and make this `[=Iterator Record=]` instead?

> +        <a abstract-op>CreateAsyncFromSyncIterator</a>(|iterator|).
+    1.  Return an [=async iterator=] value with [=JS async iterator/underlying record=] set to |iterator| and
+        [=JS async iterator/type parameter=] set to |T|.
+
+</div>
+
+
+
+<div algorithm>
+
+    To <dfn id="async-iterator-get-next-value" export lt="get an async iterator next value">get the next value</dfn> of an
+    [=async iterator=] |iterator|:
+
+    1.  Let |nextResult| be
+        <a abstract-op>IteratorNext</a>(|iterator|'s [=JS async iterator/underlying record=]).
+    1.  If |nextResult| is an abrupt completion, return [=a promise rejected with=]

All references of "abrupt completion" in the current standard link to the ES term. Could we do that too here?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/pull/1397#pullrequestreview-2287056480
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/pull/1397/review/2287056480@github.com>

Received on Friday, 6 September 2024 20:00:36 UTC