Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Add Iterator.prototype.toAsync #202

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,17 @@ <h1>Iterator.prototype.toArray ( )</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-iteratorprototype.toasync">
<h1>Iterator.prototype.toAsync ( )</h1>
<emu-alg>
1. Let _syncIteratorRecord_ be ? GetIteratorDirect(*this* value).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe hot take
1. Return ? Call(%AsyncIterator.from%, %AsyncIterator%, &laquo; *this* value &raquo;).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an additional lookup of @@asyncIterator and @@iterator, so I don't think that it's a good idea since it should work with iterators, not iterables.

1. Let _asyncIteratorRecord_ be CreateAsyncFromSyncIterator(_syncIteratorRecord_).
1. Let _wrapper_ be ! ObjectCreate(%WrapForValidAsyncIteratorPrototype%, &laquo; [[AsyncIterated]] &raquo;).
1. Set _wrapper_.[[AsyncIterated]] to _asyncIteratorRecord_.
1. Return _wrapper_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-iteratorprototype.foreach">
<h1>Iterator.prototype.forEach ( _fn_ )</h1>
<emu-alg>
Expand Down