Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions spec.html
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