Skip to content

Commit

Permalink
Editorial: use abstract closure in AsyncFromSyncIteratorContinuation (t…
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored and mathiasbynens committed Oct 18, 2021
1 parent 20b979b commit 7826358
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -38341,17 +38341,6 @@ <h1>%AsyncFromSyncIteratorPrototype%.throw ( [ _value_ ] )</h1>
1. Return ! AsyncFromSyncIteratorContinuation(_result_, _promiseCapability_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-async-from-sync-iterator-value-unwrap-functions">
<h1>Async-from-Sync Iterator Value Unwrap Functions</h1>
<p>An async-from-sync iterator value unwrap function is an anonymous built-in function that is used by AsyncFromSyncIteratorContinuation when processing the *"value"* property of an <i>IteratorResult</i> object, in order to wait for its value if it is a promise and re-package the result in a new "unwrapped" <i>IteratorResult</i> object. Each async-from-sync iterator value unwrap function has a [[Done]] internal slot.</p>
<p>When an async-from-sync iterator value unwrap function is called with argument _value_, the following steps are taken:</p>

<emu-alg>
1. Let _F_ be the active function object.
1. Return ! CreateIterResultObject(_value_, _F_.[[Done]]).
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sec-properties-of-async-from-sync-iterator-instances">
Expand Down Expand Up @@ -38383,7 +38372,7 @@ <h1>Properties of Async-from-Sync Iterator Instances</h1>
</emu-table>
</emu-clause>

<emu-clause id="sec-asyncfromsynciteratorcontinuation" aoid="AsyncFromSyncIteratorContinuation">
<emu-clause id="sec-asyncfromsynciteratorcontinuation" oldids="sec-async-from-sync-iterator-value-unwrap-functions" aoid="AsyncFromSyncIteratorContinuation">
<h1>AsyncFromSyncIteratorContinuation ( _result_, _promiseCapability_ )</h1>
<p>The abstract operation AsyncFromSyncIteratorContinuation takes arguments _result_ and _promiseCapability_ (a PromiseCapability Record). It performs the following steps when called:</p>

Expand All @@ -38394,10 +38383,10 @@ <h1>AsyncFromSyncIteratorContinuation ( _result_, _promiseCapability_ )</h1>
1. IfAbruptRejectPromise(_value_, _promiseCapability_).
1. Let _valueWrapper_ be PromiseResolve(%Promise%, _value_).
1. IfAbruptRejectPromise(_valueWrapper_, _promiseCapability_).
1. Let _steps_ be the algorithm steps defined in <emu-xref href="#sec-async-from-sync-iterator-value-unwrap-functions" title></emu-xref>.
1. Let _length_ be the number of non-optional parameters of the function definition in <emu-xref href="#sec-async-from-sync-iterator-value-unwrap-functions" title></emu-xref>.
1. Let _onFulfilled_ be ! CreateBuiltinFunction(_steps_, _length_, *""*, &laquo; [[Done]] &raquo;).
1. Set _onFulfilled_.[[Done]] to _done_.
1. Let _unwrap_ be a new Abstract Closure with parameters (_value_) that captures _done_ and performs the following steps when called:
1. Return ! CreateIterResultObject(_value_, _done_).
1. Let _onFulfilled_ be ! CreateBuiltinFunction(_unwrap_, 1, *""*, &laquo; &raquo;).
1. NOTE: _onFulfilled_ is used when processing the *"value"* property of an IteratorResult object in order to wait for its value if it is a promise and re-package the result in a new "unwrapped" IteratorResult object.
1. Perform ! PerformPromiseThen(_valueWrapper_, _onFulfilled_, *undefined*, _promiseCapability_).
1. Return _promiseCapability_.[[Promise]].
</emu-alg>
Expand Down

0 comments on commit 7826358

Please sign in to comment.