Skip to content

Commit

Permalink
Normative: make async iterators next/return/throw not pass `undefined…
Browse files Browse the repository at this point in the history
…` when value is absent (#1776)
  • Loading branch information
ljharb committed Jun 29, 2020
1 parent a4f3702 commit 18c134e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -38899,20 +38899,23 @@ <h1>The %AsyncFromSyncIteratorPrototype% Object</h1>
</ul>

<emu-clause id="sec-%asyncfromsynciteratorprototype%.next">
<h1>%AsyncFromSyncIteratorPrototype%.next ( _value_ )</h1>
<h1>%AsyncFromSyncIteratorPrototype%.next ( [ _value_ ] )</h1>
<emu-alg>
1. Let _O_ be the *this* value.
1. Assert: Type(_O_) is Object and _O_ has a [[SyncIteratorRecord]] internal slot.
1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
1. Let _syncIteratorRecord_ be _O_.[[SyncIteratorRecord]].
1. Let _result_ be IteratorNext(_syncIteratorRecord_, _value_).
1. If _value_ is present, then
1. Let _result_ be IteratorNext(_syncIteratorRecord_, _value_).
1. Else,
1. Let _result_ be IteratorNext(_syncIteratorRecord_).
1. IfAbruptRejectPromise(_result_, _promiseCapability_).
1. Return ! AsyncFromSyncIteratorContinuation(_result_, _promiseCapability_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-%asyncfromsynciteratorprototype%.return">
<h1>%AsyncFromSyncIteratorPrototype%.return ( _value_ )</h1>
<h1>%AsyncFromSyncIteratorPrototype%.return ( [ _value_ ] )</h1>

<emu-alg>
1. Let _O_ be the *this* value.
Expand All @@ -38925,7 +38928,10 @@ <h1>%AsyncFromSyncIteratorPrototype%.return ( _value_ )</h1>
1. Let _iterResult_ be ! CreateIterResultObject(_value_, *true*).
1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, &laquo; _iterResult_ &raquo;).
1. Return _promiseCapability_.[[Promise]].
1. Let _result_ be Call(_return_, _syncIterator_, &laquo; _value_ &raquo;).
1. If _value_ is present, then
1. Let _result_ be Call(_return_, _syncIterator_, &laquo; _value_ &raquo;).
1. Else,
1. Let _result_ be Call(_return_, _syncIterator_).
1. IfAbruptRejectPromise(_result_, _promiseCapability_).
1. If Type(_result_) is not Object, then
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; a newly created *TypeError* object &raquo;).
Expand All @@ -38935,7 +38941,8 @@ <h1>%AsyncFromSyncIteratorPrototype%.return ( _value_ )</h1>
</emu-clause>

<emu-clause id="sec-%asyncfromsynciteratorprototype%.throw">
<h1>%AsyncFromSyncIteratorPrototype%.throw ( _value_ )</h1>
<h1>%AsyncFromSyncIteratorPrototype%.throw ( [ _value_ ] )</h1>
<emu-note>In this specification, _value_ is always provided, but is left optional for consistency with <emu-xref title href="#sec-%asyncfromsynciteratorprototype%.return"></emu-xref>.</emu-note>

<emu-alg>
1. Let _O_ be the *this* value.
Expand All @@ -38947,7 +38954,10 @@ <h1>%AsyncFromSyncIteratorPrototype%.throw ( _value_ )</h1>
1. If _throw_ is *undefined*, then
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; _value_ &raquo;).
1. Return _promiseCapability_.[[Promise]].
1. Let _result_ be Call(_throw_, _syncIterator_, &laquo; _value_ &raquo;).
1. If _value_ is present, then
1. Let _result_ be Call(_throw_, _syncIterator_, &laquo; _value_ &raquo;).
1. Else,
1. Let _result_ be Call(_throw_, _syncIterator_).
1. IfAbruptRejectPromise(_result_, _promiseCapability_).
1. If Type(_result_) is not Object, then
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; a newly created *TypeError* object &raquo;).
Expand Down

0 comments on commit 18c134e

Please sign in to comment.