-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Editorial: spec refactor of PromiseReaction records/PromiseReactionJob #584
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34538,15 +34538,26 @@ <h1>PromiseReaction Records</h1> | |
The capabilities of the promise for which this record provides a reaction handler. | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
[[Type]] | ||
</td> | ||
<td> | ||
Either `"Fulfill"` or `"Reject"`. | ||
</td> | ||
<td> | ||
The [[Type]] is used when [[Handler]] is *undefined* to allow for behavior specific to the settlement type. | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
[[Handler]] | ||
</td> | ||
<td> | ||
A function object or a String | ||
A function object or *undefined*. | ||
</td> | ||
<td> | ||
The function that should be applied to the incoming value, and whose return value will govern what happens to the derived promise. If [[Handler]] is `"Identity"` it is equivalent to a function that simply returns its first argument. If [[Handler]] is `"Thrower"` it is equivalent to a function that throws its first argument as an exception. | ||
The function that should be applied to the incoming value, and whose return value will govern what happens to the derived promise. If [[Handler]] is *undefined*, a function that depends on the value of [[Type]] will be used instead. | ||
</td> | ||
</tr> | ||
</tbody> | ||
|
@@ -34697,7 +34708,7 @@ <h1>RejectPromise ( _promise_, _reason_ )</h1> | |
<!-- es6num="25.4.1.8" --> | ||
<emu-clause id="sec-triggerpromisereactions" aoid="TriggerPromiseReactions"> | ||
<h1>TriggerPromiseReactions ( _reactions_, _argument_ )</h1> | ||
<p>The abstract operation TriggerPromiseReactions takes a collection of PromiseReactionRecords and enqueues a new Job for each record. Each such Job processes the [[Handler]] of the PromiseReactionRecord, and if the [[Handler]] is a function, calls it passing the given argument.</p> | ||
<p>The abstract operation TriggerPromiseReactions takes a collection of PromiseReactionRecords and enqueues a new Job for each record. Each such Job processes the [[Type]] and [[Handler]] of the PromiseReactionRecord, and if the [[Handler]] is a function, calls it passing the given argument. If the [[Handler]] is *undefined*, the behavior is determined by the [[Type]].</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assert seems unhelpful as "defined" is not a real term. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted some kind of assertion so that implementations know that no other There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want that, I'd change the second bullet to "Otherwise, type is |
||
<emu-alg> | ||
1. Repeat for each _reaction_ in _reactions_, in original insertion order | ||
1. Perform EnqueueJob(`"PromiseJobs"`, PromiseReactionJob, « _reaction_, _argument_ »). | ||
|
@@ -34740,14 +34751,16 @@ <h1>PromiseReactionJob ( _reaction_, _argument_ )</h1> | |
<emu-alg> | ||
1. Assert: _reaction_ is a PromiseReaction Record. | ||
1. Let _promiseCapability_ be _reaction_.[[Capabilities]]. | ||
1. Let _type_ be _reaction_.[[Type]]. | ||
1. Let _handler_ be _reaction_.[[Handler]]. | ||
1. If _handler_ is `"Identity"`, let _handlerResult_ be NormalCompletion(_argument_). | ||
1. Else if _handler_ is `"Thrower"`, let _handlerResult_ be Completion{[[Type]]: ~throw~, [[Value]]: _argument_, [[Target]]: ~empty~}. | ||
1. If _handler_ is *undefined*, then | ||
1. If _type_ is `"Fulfill"`, let _handlerResult_ be NormalCompletion(_argument_). | ||
1. Otherwise, _type_ is `"Reject"`. Let _handlerResult_ be Completion {[[Type]]: ~throw~, [[Value]]: _argument_, [[Target]]: ~empty~}. | ||
1. Else, let _handlerResult_ be Call(_handler_, *undefined*, « _argument_ »). | ||
1. If _handlerResult_ is an abrupt completion, then | ||
1. Let _status_ be Call(_promiseCapability_.[[Reject]], *undefined*, « _handlerResult_.[[Value]] »). | ||
1. Return Completion(_status_). | ||
1. Let _status_ be Call(_promiseCapability_.[[Resolve]], *undefined*, « _handlerResult_.[[Value]] »). | ||
1. Else, | ||
1. Let _status_ be Call(_promiseCapability_.[[Resolve]], *undefined*, « _handlerResult_.[[Value]] »). | ||
1. Return Completion(_status_). | ||
</emu-alg> | ||
</emu-clause> | ||
|
@@ -35034,11 +35047,11 @@ <h1>PerformPromiseThen ( _promise_, _onFulfilled_, _onRejected_, _resultCapabili | |
1. Assert: IsPromise(_promise_) is *true*. | ||
1. Assert: _resultCapability_ is a PromiseCapability record. | ||
1. If IsCallable(_onFulfilled_) is *false*, then | ||
1. Let _onFulfilled_ be `"Identity"`. | ||
1. Let _onFulfilled_ be *undefined*. | ||
1. If IsCallable(_onRejected_) is *false*, then | ||
1. Let _onRejected_ be `"Thrower"`. | ||
1. Let _fulfillReaction_ be the PromiseReaction { [[Capabilities]]: _resultCapability_, [[Handler]]: _onFulfilled_ }. | ||
1. Let _rejectReaction_ be the PromiseReaction { [[Capabilities]]: _resultCapability_, [[Handler]]: _onRejected_}. | ||
1. Let _onRejected_ be *undefined*. | ||
1. Let _fulfillReaction_ be the PromiseReaction { [[Capabilities]]: _resultCapability_, [[Type]]: `"Fulfill"`, [[Handler]]: _onFulfilled_ }. | ||
1. Let _rejectReaction_ be the PromiseReaction { [[Capabilities]]: _resultCapability_, [[Type]]: `"Reject"`, [[Handler]]: _onRejected_ }. | ||
1. If the value of _promise_'s [[PromiseState]] internal slot is `"pending"`, then | ||
1. Append _fulfillReaction_ as the last element of the List that is the value of _promise_'s [[PromiseFulfillReactions]] internal slot. | ||
1. Append _rejectReaction_ as the last element of the List that is the value of _promise_'s [[PromiseRejectReactions]] internal slot. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comma is superfluous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it makes the prose read better, but sure, I can remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.